1
I have a problem in a service of AngularJS
, after a consultation REST
using RestAngular
in return 401, need to be able to call a method of the service in which it is inserted. The problem is that when calling it I get the message:
this.retrieveToken is not a Function.
Apparently the scope of the Handling error is not the same as the service, and so 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... };
}]);
Thanks for the reply! Gave to have a good idea. :)
– Cristiano Siebert