應用程序代碼如下所示:AngularJS - ngRoute未加載?
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(['$routeProvider', function($routeProvider){
$routeProvider.
when('/login', {
templateUrl: 'views/login.html',
controller: 'RegistrationController'
}).
when('/register', {
templateUrl: 'views/register.html',
controller: 'RegistrationController'
}).
when('/succes', {
templateUrl: 'views/success.html',
controller: 'SuccessController'
}).
othervise({
redirectTo: '/login'
});
}]);
,我會運行它拋出一個錯誤:
Uncaught Error: [$injector:modulerr]
at angular.js:88
at angular.js:4957
at p (angular.js:410)
at g (angular.js:4917)
at gb (angular.js:4839)
at c (angular.js:1949)
at Uc (angular.js:1970)
at xe (angular.js:1855)
at angular.js:33826
at HTMLDocument.b (angular.js:3468)
,但我有angular-route
裝
<script src="js/lib/angularjs/angular.min.js"></script>
<script src="js/lib/angularjs/angular-route.min.js"></script>
<script src="js/app.js"></script>
任何線索,爲什麼它表明ngRoute沒有加載?
什麼是完整的錯誤信息告訴你關於哪個模塊不可用?注意如果你使用angular的開發版本會得到更詳細的錯誤輸出 – charlietfl
你有沒有檢查你的應用名稱? – 2017-08-03 18:11:17
@AvrilLavigne是一樣的 - 'myApp' – JackTheKnife