I have a problem with a service of AngularJS
, after a query REST
using RestAngular
with return 401 , I need to be able to call a service method in which it is inserted. The problem is that when calling the same I get the message:
this.retrieveToken is not a function.
Apparently the scope of error handling is not the same as the service, so it does not recognize the method. Is there a way to do this? My code is currently like this:
util.service('Util',[dependencies... {
this.buscar = function (addr,options) {
Restangular.setFullResponse(true);
var result = Restangular.all(addr).getList(options);
result.then(function(response){ //success },
function(error){
//O PROBLEMA ACONTECE AQUI
this.retrieveToken();
});
};
this.retrieveToken = function (){ //code... };
}]);