$injector:modulerr ng-route 错误
$injector:modulerr error 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>
angular-路由的脚本标签必须关闭。
我正在尝试设置一些基本路由,但在控制台中一直遇到 [$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>
angular-路由的脚本标签必须关闭。