I've been modifying a login script created by someone else. My objective was to incorporate the use of ng-option
instead of input
. I successfully implemented this, as shown in the example. However, after logging in, I'm unable to view the user's data. Why is that?
FULL CODE: http://plnkr.co/edit/ImsqhVFVanCp5OXNisrA?p=preview
Controllers.js:
angular.module('Authentication')
.controller('LoginController',
['$scope', '$rootScope', '$location', 'AuthenticationService',
function ($scope, $rootScope, $location, AuthenticationService) {
// reset login status
AuthenticationService.ClearCredentials();
$scope.users = [
{"username": "test", "number": "13242342"},
{"username": "2", "number": "00000000"},
{"username": "3", "number": "0483184"},
];
$scope.login = function () {
$scope.dataLoading = true;
AuthenticationService.Login($scope.username, $scope.password, function(response) {
if(response.success) {
AuthenticationService.SetCredentials($scope.username, $scope.password);
$location.path('/');
} else {
$scope.error = response.message;
$scope.dataLoading = false;
}
});
};
}]);