angularjs中的简单路由

angularjs中的简单路由,angularjs,routes,Angularjs,Routes,我在Angular中有以下两个文件,希望创建一个简单的登录应用程序。第一个是Login.html: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> AngularJS Login SPA</title> <script src="https://ajax.googleapis.com/aja

我在Angular中有以下两个文件,希望创建一个简单的登录应用程序。第一个是Login.html:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title> AngularJS Login SPA</title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>   
        <script src="angular-route.min.js"></script>   
        <script src="controller.js"></script>
    </head>
    <body ng-app="mainApp">
        <div ng-controller="loginCtrl">
            <form action="/" id="myLogin">
                Username: <input type="text" name="username" id="username" ng-model="username"><br/>
                Password: <input type="password" name="password" id="password" ng-model="password"><br/>
                <button type="button" ng-click="submit()">Login</button>
            </form>
        </div>
    </body>
</html>
问题是,在我成功地在用户名和密码上输入文本“admin”和“admin”后,如果我单击其他按钮,则会正确显示警报,地址会更改为…/index.html/dashboard,但它不会加载dashboard.html页面,这是我为此应用程序创建的一个简单页面,位于index.html所在的同一文件夹中

在我用两个文本成功登录后,它如何显示dashboard.html?
非常感谢您的帮助。

我发现了问题所在。 我不得不在Mozilla中测试这个应用程序,因为Google Chrome不支持可以与运行中的服务器相匹配的SPAs单页应用程序

var app = angular.module("mainApp", ['ngRoute']);

app.config(function($routeProvider) {
$routeProvider
.when ('/', {
    templateUrl: 'login.html'
})
.when ('#/dashboard',{
    resolve:{
        "check":function($location, $rootScope){
            if (!$rootScope.loggedIn)
            {
                $location.path('/dashboard');
            }
            else{

            }
        }
    },
    templateUrl: 'dashboard.html'

})
.otherwise ({
    redirectTo: '/'
})
});

app.controller('loginCtrl', function($scope, $location, $rootScope){
$scope.submit = function(){


    if($scope.username == 'admin' && $scope.password == 'admin')
    {
        $rootScope.uname = $scope.username;
        $rootScope.password = $scope.password;
        $rootScope.loggedIn = true;
        $location.path('/dashboard');
    }
    else{
        alert('wrong stuff');
    }
};
});