javascript - How to test for success after calling a AngularJS factory service -
i wondering how check wether or not function successfull or had error. check in function itself. how can recheck result when calling service.
i've tried this
entryservice.update($scope.entry) .success(function(){ $scope.entry = data; $state.go('entry', {id: $scope.entry._id}); }).error(function(){ error = true; });
this doesn't work. , wondering how similar result?
my service funtion looks this:
angular.module('academiaunitateapp') .factory('entryservice',function($http){ var service = {}; service.update = function(entry, callback){ $http.put('/api/entrys/' + entry._id, entry) .success(callback, function(data){ console.log('updated entry : ', data); }) .error(callback, function(error){ console.log("couldn't update entry. error : ", error); }); }; return service; });
you can return true or false function success or failure.
Comments
Post a Comment