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/?#/
该怎么解决??
It should be a problem with the href address of a link
Temporarily block your resolve
It is obvious here that it is used for login verification. If the verification is unsuccessful, it will be redirected to http://localhost:8000/?#/