I have the following code which works when I call it from a controller. It
gets all records from a database table. I would like to have more functions
in the same app factory like getByID, update, remove, etc all using the
defer object. I am having trouble trying to code this factory for multiple
functions within this factory that I can call from a controller.
app.factory('getAllActivities', function ($http, $q) {
return {
getAll: function(reqId) {
var deferred = $q.defer();
$http.post('GetData.php', {command : 'getAll'})
.success(function(data) {
deferred.resolve(data);
})
.error(function(msg, code) {
deferred.reject(msg);
$log.error(msg, code);
});
return deferred.promise;
}
}
});
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.