Hi Jim,

Your code is needlessly complex, $http returns a promise to begin with.

    app.factory('getAllActivities', function ($http, $q) {
        return  {
            getAll: $http.post('GetData.php', {command : 'getAll'})
        }
    }

    app.factory('getAllActivities', function ($http, $q) {
        var all = $http.post('GetData.php', {command : 'getAll'})
        return  {
            getAll: all,
            getId: function (id) {}
               return $http.post('GetData.php', {command : 'getId',id:id})
            }
        return  {
        }
    }

The first service is exactly the same as your version, with the exception 
that you will retrieve the complete response, in stead of just the data 
(hence, you need to use result.data in your code)
the second one does only does 1 $http request and keeps that for reuse 
trough the entire life-cycle of your app, and the second method can fetch 
an id. (you probably want to do that every time…)

Does this help you enough? if you have additional questions, don’t hesitate 
to ask!

Regards
Sander
​

-- 
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.

Reply via email to