AngularJs路由文件不工作

AngularJs路由文件不工作,angularjs,angularjs-routing,Angularjs,Angularjs Routing,我没有收到任何错误,但我无法得到我的工作路线。任何帮助都将不胜感激。谢谢 main.html <!DOCTYPE html> <html ng-app = 'ContactsApp'> <!--ng app is bootstrapping application and it is called contactsapp like in the anuglar app.js file----> <h

我没有收到任何错误,但我无法得到我的工作路线。任何帮助都将不胜感激。谢谢

main.html

<!DOCTYPE html>
    <html ng-app = 'ContactsApp'>
            <!--ng app is bootstrapping application and it is called contactsapp like in the anuglar     app.js file---->
        <head>

            <title>Contacts</title>
            <base href = '/'>
            <link rel = 'stylesheet' href = "src/bootstrap.min.css">
            <!---base elemnt with a href attr of root 
            ...angular will use the base element and the href tells it what to use when it goes to get our front end resources so it will start with the root ----> 
        </head>


        <body>
            <div class = 'container'>

                <div class = "page-header">


                <h1>Contacts{{message}}</h1>

            </div>

                    <!---row and colsm12 are twitter bootstrap classes the ng view is anuglar it is saying that this will be the view div on the page so the contents of this page will change as our route changes---->

            <div class = 'row'>
                <div class = 'col-sm-12' ng-view></div>
            </div> 


            <script src = 'lib/jquery/dist/jquery.min.js'></script>
            <script src = 'lib/bootstrap/dist/js/bootstrap.min.js'></script>
            <script src = 'lib/node_modules/angular/angular.js'></script>
            <script src = 'lib/node_modules/angular-route/angular-route.min.js'> </script>
            <script src = 'lib/angular-resource/angular-resource.min.js'></script>
            <script src = 'src/app.js'></script>
            <script src = 'src/controllers.js'></script>
            <script src = 'src/factories.js'></script>
        </body>

    </html>
controller.js

         angular.module('ContactsApp', [])
           .controller('ListController', function($scope){
             $scope.contacts = [];
        });
angular.module('listControllers', [])

.controller('ListController', function($scope){
    $scope.contacts = [];
});

我发现你的代码中有两个问题

第一个问题是,您使用ContactsApp名称定义了模块两次

为具有控制器的模块指定一个不同的名称,并在主模块中将其声明为依赖项

像这样:

app.js

            angular.module('ContactsApp',['ngRoute'])

            .config(function($routeProvider, $locationProvider)
                    {
                        $routeProvider
                        .when('/contacts'), {
                            controller: 'ListController',
                            templateUrl: 'views/list.html'
                        };

                    });
angular.module('ContactsApp',['ngRoute','listControllers'])

.config(function($routeProvider, $locationProvider) {
     $routeProvider
     .when('/contacts'), {
          controller: 'ListController',
          templateUrl: 'views/list.html'
      };
});
controller.js

         angular.module('ContactsApp', [])
           .controller('ListController', function($scope){
             $scope.contacts = [];
        });
angular.module('listControllers', [])

.controller('ListController', function($scope){
    $scope.contacts = [];
});
第二个问题是main.html中的输入错误:

<script src = 'lib/node_modules/angular-route/angular-route.min.js'script>

应该是:

<script src = 'lib/node_modules/angular-route/angular-route.min.js'></script>


angular route.min.js脚本标记未正确关闭。很高兴我能提供帮助。如果这回答了您的问题,不要忘记将其标记为已接受的答案。