1
如何向角度種子項目添加更多視圖?向角度種子項目添加視圖
我剛開始這個項目,想添加更多的視圖,所以我複製了view2文件夾並將其重命名爲view3(對包含view2變量的文件夾中的所有文件都做了相同的處理),然後將其添加到模塊中。
angular.module('myApp', [
'ngRoute',
'myApp.view1',
'myApp.view2',
'myApp.view3',
'myApp.version'
]).
config(['$routeProvider', function($routeProvider) {
$routeProvider.otherwise({redirectTo: '/view1'});
}]);
的view3.js文件看起來像這樣:
'use strict';
angular.module('myApp.view3', ['ngRoute'])
.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view3', {
templateUrl: 'view3/view3.html',
controller: 'View3Ctrl'
});
}])
.controller('View3Ctrl', [function() {
}]);
還有什麼角度種子相關的,你需要做的,因爲我得到這些錯誤,當我重新加載頁面和我不真的不知道從哪裏開始。一直在看Bower_components文件夾,但似乎沒有任何內容,你應該改變。
第三行討論加載它,但加載它在哪裏?
Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to:
Error: [$injector:modulerr] Failed to instantiate module myApp.view3 due to:
Error: [$injector:nomod] Module 'myApp.view3' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
http://errors.angularjs.org/1.2.23/$injector/nomod?p0=myApp.view3
at http://localhost:8000/app/bower_components/angular/angular.js:78:12
at http://localhost:8000/app/bower_components/angular/angular.js:1677:17
at ensure (http://localhost:8000/app/bower_components/angular/angular.js:1601:38)
at module (http://localhost:8000/app/bower_components/angular/angular.js:1675:14)
at http://localhost:8000/app/bower_components/angular/angular.js:3878:22
at forEach (http://localhost:8000/app/bower_components/angular/angular.js:325:18)
at loadModules (http://localhost:8000/app/bower_components/angular/angular.js:3872:5)
at http://localhost:8000/app/bower_components/angular/angular.js:3879:40
at forEach (http://localhost:8000/app/bower_components/angular/angular.js:325:18)
at loadModules (http://localhost:8000/app/bower_components/angular/angular.js:3872:5)
http://errors.angularjs.org/1.2.23/$injector/modulerr?p0=myApp.view3&p1=Err…ocalhost%3A8000%2Fapp%2Fbower_components%2Fangular%2Fangular.js%3A3872%3A5)
at http://localhost:8000/app/bower_components/angular/angular.js:78:12
at http://localhost:8000/app/bower_components/angular/angular.js:3906:15
at forEach (http://localhost:8000/app/bower_components/angular/angular.js:325:18)
at loadModules (http://localhost:8000/app/bower_components/angular/angular.js:3872:5)
at http://localhost:8000/app/bower_components/angular/angular.js:3879:40
at forEach (http://localhost:8000/app/bower_components/angular/angular.js:325:18)
at loadModules (http://localhost:8000/app/bower_components/angular/angular.js:3872:5)
at createInjector (http://localhost:8000/app/bower_components/angular/angular.js:3812:11)
at doBootstrap (http://localhost:8000/app/bower_components/angular/angular.js:1444:20)
at bootstrap (http://localhost:8000/app/bower_components/angular/angular.js:1459:12)
http://errors.angularjs.org/1.2.23/$injector/modulerr?p0=myApp&p1=Error%3A%…calhost%3A8000%2Fapp%2Fbower_components%2Fangular%2Fangular.js%3A1459%3A12)
哈哈... doh! 謝謝你! – thehindutimes 2014-09-05 13:43:42
我也是愚蠢的。 :D Stackoverflow也需要這些類型的問題。 – Daniel 2014-12-02 17:04:01