【发布时间】:2016-02-22 13:45:50
【问题描述】:
我正在处理其他人已经制作的登录脚本。我的目标实际上是整合使用ng-option 而不是input。正如您从示例中看到的那样,这很有效。但是当我登录时,我看不到用户的数据。为什么?
完整代码: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;
}
});
};
}]);
【问题讨论】:
-
我希望你意识到你不能在浏览器中进行授权......所有的登录凭据都暴露在你的脚本中
-
当然,我只是在做一些测试来学习更好的角度:D
-
只是检查......你会在这里看到很多奇怪的误解
标签: javascript angularjs angularjs-directive angular-ui-router