Within an angular controller designed for user login functionality, the code snippets below are extracted from an angular-meteor tutorial:
this.login = function() {
Meteor.loginWithPassword(this.credentials.email, this.credentials.password, (err) => {
if (err) {
this.error = err.reason;
}
else {
$state.go('index');
}
});
};
and:
this.login = function() {
Meteor.loginWithPassword(this.credentials.email, this.credentials.password, function(err) {
if (err) {
this.error = err.reason;
}
else {
$state.go('index');
}
});
};
The first snippet triggers AngularJS to update the error value after the callback function is executed. However, the second snippet does not trigger an update. The key difference between the two lies in the use of shorthand method declaration in the first one. What could be the underlying reason for this discrepancy?