Check out the section titled "The Promise API" in the docs on the $q service. You can also checkout this video on Angular promises.
The main method you need to know about is .then
. Here's how you could refactor your code with this method:
gridData.query(function(promise) {
promise.then(function (result) {
console.log("result is");
console.log(result);
$scope.data = result;
});
});
This example could be cleaner, but it works for illustrative purposes. Hope that helps.