我建立一個基本AngularJS登錄頁面和$ window.location.href沒有再直接在頁面一個新的HTML在我的系統,託管由WAMP。我甚至嘗試將它重新引導到谷歌。什麼都沒發生。我在這裏嘗試了所有可用的解決方案,似乎沒有任何工作。任何解決方案
JS其次是HTML
var app = angular.module('myApp', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
$scope.submit = function() {
if ($scope.username && $scope.password) {
var user = $scope.username;
var pass = $scope.password;
if (pass == "admin" && user == "[email protected]") {
alert("Login Successful");
$window.location.href = "http://google.com"; //Re-direction to some page
} else if (user != "[email protected]") {
alert("Invalid username");
} else if (pass != "admin" && user == "[email protected]") {
alert("Invalid password");
}
} else {
alert("Invalid Login");
}
}
});
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="login.js"></script>
<link rel="stylesheet" href="login.css">
</head>
<body ng-controller="MainCtrl">
<form>
<label>Username:</label>
<input type="email" ng-model="username" class="lab1" />
</br>
</br>
<label></label>Password:</label>
<input type="password" ng-model="password" class="lab2">
</br>
<button type="submit" ng-click="submit()" class="buttonclass">login</button>
</form>
</body>
</html>
嘗試的字符串沒有'$'符號。 ** window.location.href =「[email protected]」** – Niklas
使用基本的Javascript窗口重定向..即沒有$。 window.location.href。 – Amarnath
它的工作。謝謝:)但爲什麼它不與美元符號一起工作? –