I have a controller which calls the api.
$scope.getUserDetails = function(){
var promise = userService.getPromise();
promise.then(function(user){
if(user.error){
//handle error
} else {
//perform other task
}
}.bind(this));
};
but I am not able to understand that what does this bind function do.
bind(this)sets the context of the function it is called on, so ifthisis used inside that function, it will refer tothisthat was passed tobind. Perhaps there is some code inside of that function that would callthisandthisneeds to be set correctly. It's all a bit awkward. There's probably a better way to do whatever is trying to be done there.