javascript - Angular custom method on $resource with .then() function causing error -
i have in angular service:
return $resource(base + '/cases/:id', {id: '@id'}, { status: {method: 'get', params: {status: '@status'}} });
when using method added $resource
definition along promise's .then()
function, i'm getting error:
cases.status({status: 'pending'}) .then(function(res) { console.log(res); $scope.cases.pending = res.data.cases; }) .then(function() { $scope.tabbed.pending = true; });
after above snippet run, error is:
typeerror: undefined not function
on line: .then(function(res) {
can not use these functions when i'm using method defined on $resource
?
i think need use $promise
of $resource
object call success function when actual promise gets resolved & proceed promise chain.
code
cases.status({status: 'pending'}) .$promise .then(function(res) { console.log(res); $scope.cases.pending = res.data.cases; }) .then(function(cases) { $scope.tabbed.pending = true; });
Comments
Post a Comment