var app = angular.module('myApp', ['ngRoute']);
app.config(function($routeProvider) {
$routeProvider.when('/', {
templateUrl: 'login.html',
})
.when('/dashboard', {
resolve: {
"check": function($location, $rootScope) {
if (!$rootScope.loggedIn) {
$location.path('/');
}
}
},
templateUrl: 'dashboard.html'
})
.otherwise({
redirectTo: '/'
});
});
app.controller('loginCtrl', function($scope, $location, $rootScope) {
$scope.submit = function() {
if ($scope.username == 'admin' && $scope.password == 'admin') {
$rootScope.loggedIn = true;
$location.path('/dashboard');
} else {
alert('Wrong!');
$location.path('/');
}
};
})
我打開網頁的時候是http://localhost:8000/#/ ,登陸的時候是想變成http://localhost:8000/#/dashb... ,但是進行操作後路徑卻變成了http ://localhost:8000/?#/
該怎麼解決? ?
應該是a連結 href地址的問題
暫時屏蔽你的resolve
這裡很明顯,是做登陸校驗的,校驗不成功會重定向至http://localhost:8000/?#/