Asynchronously Populating An Angularjs Ngtable With Json Data
I'm trying to build an AngularJS app, which outputs an HTML table that I populate with json (the table's HTML is at the bottom of this question).  I'm using application/json data t
Solution 1:
Definitely worth looking at ngResource - this will simply take out all the heavy lifting for you.
On another note, I suspect you don't need to do this:
App2.factory('getTasks', function($http) {
    return {
        getJson: function() {
            var url = 'http://myurl.local/todo/api/v1/tasks';
            var promise = $http.get(url);
            return promise.then(function(result) {
                return result.data;
            });
        }
    }
});
i would change it to :
 App2.factory('getTasks', function($http) {
    return {
        getJson: function() {
            var url = 'http://myurl.local/todo/api/v1/tasks';
            return$http.get(url);
        }
    }
});
As $http returns the promise. That means this bit still works:
    getTasks.getJson().then(function(data) {
        $scope.data = data;
    });
Post a Comment for "Asynchronously Populating An Angularjs Ngtable With Json Data"