我正試圖讓AngularJS 1.2 RC2應用程序啓動並運行。目前,我一直在使用Angular Seed項目來嘗試啓動並運行我的應用程序。不幸的是,Angular Seed項目使用v1.0.7。從角種子工程,我已經更新了依賴關係如下所示:
$script([
'res/js/angular-1.2.0-rc.2.js',
'res/js/angular-route-1.2.0-rc.2.js',
'res/js/app.js?v=2',
], function() {
// when all is done, execute bootstrap angular application
angular.bootstrap(document, ['myApp']);
});
在app.js,我有以下幾點:
'use strict';
angular.module('myApp', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/home'});
}]);
當我運行這個程序,我得到的以下錯誤:
Error: [$injector:unpr] Unknown provider: $routeProvider
我讀過一些這樣說:1的其他反應的)進樣「ngroute」或2)您需要定義在路由控制器。我的問題是,我不明白如何注入ngroute。另外,我真的需要在路線中定義控制器嗎?這種方法看起來不可擴展。我的應用可能有一千個視圖。在我看來,似乎必須有方法來定義路線,而不必加載所有的控制器。
您是否嘗試在您的'myApp'模塊定義中添加ngRoute,例如'angular.module('myApp',['ngRoute'])。' – Chandermani
這個問題應該在Angular js視頻教程中進行關聯,其中的一切工作在教練演示上都很完美。 – Rohit