我是Angular JS的初学者。我创建了一个简单的登录页面。登录过程 [警报正在运行] 后,我无法导航到下一页。这段代码有什么错吗??这是我的代码......
HTML页面
<body ng-app="mainApp">
<div ng-controller="Login1ctrl">
<div class="main">
<div class="imgcontainer">
<img src="login.jpg" alt="Avatar" class="avatar">
</div>
<div class="container">
<label><b>Username</b></label>
<input type="text" name="username" id="username" ng-model="username">
<label><b>Password</b></label>
<input type="password" name="password" id="password" ng-model="password">
<button type="submit" ng-click="submit()">Login</button>
</div>
</div>
</div>
</div>
</body>
我的Js页面..
var app = angular.module('mainApp', [])
app.controller('Login1ctrl', ['$scope', function($scope) {
$scope.submit = function() {
var uname = $scope.username;
var password = $scope.password;
if ($scope.username == 'admin' && $scope.password == 'admin') {
alert($scope.username);
window.location = '#/dashboard.html';
/*$location.path('/dashboard.html');*/
} else {
alert("UserName & Password is Incorrect");
/*window.location = '#/login.html';
$location.path('/login.html');*/
}
};
}]);
谢谢..