1
Ich verwende eckige $ Ressource. Hier ist mein Service:
.factory('EventSubCategory', function($resource) {
// Might use a resource here that returns a JSON array
return $resource("http://localhost:3000/api/event_sub_categories");
// Some fake testing data
})
Und hier ist der Controller, wo ich es nennen:
.controller('ActivityDashboardCtrl', function($scope, $state, EventCategory, EventForm, EventSubCategory) {
$scope.createSubCategory = function(sub_categories){
console.log(sub_categories);
EventSubCategory.$save(sub_categories);
}
})
Allerdings, wenn ich dies tun, bekomme ich diesen Fehler in der Browser-Konsole:
ionic.bundle.js:25642 TypeError: EventSubCategory.$save is not a function
at Scope.$scope.createSubCategory (controllers.js:43)
at fn (eval at <anonymous> (ionic.bundle.js:26457), <anonymous>:4:362)
at callback (ionic.bundle.js:36610)
at Scope.$eval (ionic.bundle.js:29158)
at Scope.$apply (ionic.bundle.js:29257)
at HTMLFormElement.<anonymous> (ionic.bundle.js:36615)
at HTMLFormElement.eventHandler (ionic.bundle.js:16583)
at triggerMouseEvent (ionic.bundle.js:2948)
at tapClick (ionic.bundle.js:2937)
at HTMLDocument.tapMouseUp (ionic.bundle.js:3013)
Ich habe versucht, meinen Controller zu ändern:
Vielen Dank. Bin dankbar. – Philip7899