我有一个评估使用angularjs 用户名和密码登录页面,但似乎我在控制器条件语句返回false,即使我把一个真实值如果angularjs语句不工作
,这里是我的html文件
<div class="row">
<form action="/">
<input type="text" class="form-control" id="username" ng-model="username" required>
<input type="Password" class="form-control" id="username" ng-model="password" required>
<br>
<button type="button" style="width: 40%;" ng-click="submit()"> Log In </button>
</form>
</div>
和我的控制器
var app = angular.module('myApp', ["ngRoute"]);
app.controller('ctrl',
function($scope, $location) {
$scope.submit = function() {
var username = $scope.username;
var password = $scope.password;
if($scope.username == 'admin' && $scope.password == 'admin') {
console.debug('success');
} else {
console.debug('fail');
}
}
});
我每次在用户名和密码,我总是得到输入“管理员”在“失败”
我的控制台意味着提交函数返回false。 。
' sevenseacat
opps类型多数民众赞成在应该是id =“密码”,但我认为这不会导致问题,因为即时通讯不使用id atm如果我没有错 –
你可以让你的问题说明你的问题 – gh9