我在链接页面时遇到了问题。假设,从URL“/admin_1_angularjs/login.html”登录后,
dashboard.html页面应显示在此网址“/admin_1_angularjs/#/dashboard.html”中。相反,它出现在“/admin_1_angularjs/#/login.html”链接中。我该如何解决?这是我的angularJS控制器...
MetronicApp.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
// Redirect any unmatched url
$urlRouterProvider.otherwise("/login.html");
app.version = '1454574448';
$stateProvider.state('login', {
url: "/login.html",
templateUrl: 'login.html?_=' + app.version,
controller: 'login'
})
.state('dashboard', {
url:"/dashboard.html",
templateUrl: 'views/profile/dashboard.html?_=' + app.version,
controller: 'dashboard'
})
这是我的登录控制器。
var app = angular.module('myApp', []);
app.controller('login', ['$window','$scope','$timeout', function ($window,$scope,$timeout) {
$scope.hasError = false;
$scope.errorMessage = "";
$scope.input = {
username: '',
password: ''
};
$scope.counter = 0;
$scope.isLoading = false;
$scope.setError = function (hasError) {
$scope.hasError = hasError;
};
$scope.login = function () {
$scope.isLoading = true;
var postData = {
clazz: "com.smk.aps.server.model.rpc.request.RPCAdminLogin",
signature: "",
data: {
// requestLoginID: app.uuid.v4(),
// requestUsername: $scope.input.username,
// requestPassword: CryptoJS.SHA1($scope.input.password).toString()
}
};
postData.data._class = postData.clazz;
$timeout(function (data,status) {
$scope.isLoading = false;
if ($scope.hasError = true) {
if($scope.counter == 0) {
$scope.errorMessage = "Invalid username or password. Error code = " + $scope.counter;
console.log($scope.errorMessage);
$scope.counter++;
} else if ($scope.counter == 1) {
$scope.errorMessage = "Server busy please try again later. Error code = " + $scope.counter;
console.log($scope.errorMessage);
$scope.counter++;
} else {
$window.location.href = "/admin_1_angularjs/";
}
}
}, 2000);
答案 0 :(得分:0)
您必须将HTML5模式设置为true才能获得所需的结果。有关更多详细信息,请参阅以下链接的HTML5Mode部分。