I have the following controller:
我有以下控制器:
'use strict';
angular.module('App')
.controller('LoginCtrl', function ($scope, $state, Login, localStorageService, Message, authService) {
$scope.submit = function() {
if (this.username) {
var credentials = {
username: this.username,
password: this.password
};
Login.post(credentials).then(function(data) {
if (data.status === 200) {
authService.loadCustomer(data.data);
$state.go(authService.nextPath() || 'curator');
}
},
function(data) {
if (data.status === 401) {
$scope.password = '';
Message.error('Wrong e-mail/password combination');
}
else {
Message.error('An error occured while logging in.');
}
});
}
}
});
'