$ injector:modulerr error ng-route

时间:2015-02-11 15:32:43

标签: angularjs angularjs-ng-route

我正在尝试设置一些基本路由,但继续面对控制台中的[$injector:modulerr]错误。我已经在我的应用程序中包含了angular-route.js,因为它已经被移动到它自己的模块中。但是,我仍然会收到此错误。

JS:

// App initialiser
var module = angular.module('MyApp', ['ngRoute']);


// Routing config
module.config(function($routeProvider){

    $routeProvider.
        when('/NewOrder', {
            templateUrl: 'templates/addOrder.htm',
            controller: 'addOrderController'
        }).
        when('/ShowOrders', {
            templateUrl: 'templates/showOrders.htm',
            controller: 'showOrdersController'
        }).
        otherwise({
            redirectTo: '/NewOrder'
        });

});

// Add Order Controller
module.controller('addOrderController', function($scope){
    $scope.message = "This is the Add Order screen.";
});

// Show Orders Controller
module.controller('showOrdersController', function($scope){
    $scope.message = "This is the Show Orders screen.";
});

HTML(ng-app包含在我的html标签中):

<div class="container">

    <nav>
        <ul>
            <li><a href="#NewOrder"> New Order </a></li>
            <li><a href="#"> New Contact </a></li>
            <li><a href="#ShowOrders"> Show Orders </a></li>
            <li><a href="#"> Show Contacts </a></li>
        </ul>
    </nav>

    <div ng-view="">

    </div>

</div>


<!--SCRIPTS-->
<script type="text/javascript" src="vendor/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.13/angular-route.min.js">

<script type="text/javascript" src="scripts/controller.js"></script>

1 个答案:

答案 0 :(得分:1)

必须关闭angular-route的脚本标记。