angularjs - How to use promises with Angular.js and $resource with query string? -


what's best way handle promises in angular.js resource expects query string / parameters passed it? i've seen job of $q handled in factory, controller , router i'm not sure how handle in case when there's parameters involved.
if factory :

angular.module(animals, ['$resource', '$route', '$location', function($resource, $route, $location) {   return $resource('http://thezoo.com/animals', { query: {method: 'get', isarray: true}}); }]); 

and controller:

animals.query({size="med",gender='f'}); 

then how should best handled using promises? call external resource can take quite long.

really late party, found page google. if want use resource, maybe want data query method before continue (maybe you're writing in resolve or something), can this.

var deferred = $q.defer(); resource.query({params}, function (response) {   somedata = response;   deferred.resolve(somedata); }); return deferred.promise; 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -