簡體   English   中英

Angular JS添加額外的模塊會導致項目無法呈現任何頁面

[英]Angular JS adding an extra module causes project to not render any pages

抱歉,如果這是一個菜鳥問題,但我是Angular JS的新手。

在對我的Web應用進行編程時,我想向我的網站添加一個額外的頁面。 目前,我有一個主模塊,其中包含每個網頁的較小模塊:

'use strict';
angular.module('myApp', [
  'ngRoute',
  'myApp.view1',
  'myApp.view2',
  'myApp.version',
  'ui.bootstrap'
]).
config(['$routeProvider', function($routeProvider) {
  $routeProvider.otherwise({redirectTo: '/view1'});
}]);

這可以正常工作,但是當我嘗試添加額外的模塊“ myApp.view3”時,所有頁面均無法呈現。 以下是這些模塊的外觀:

廠景

angular.module('myApp.view1', ['ngRoute'])
// configuration
.config(['$routeProvider',
    function ($routeProvider) {
        $routeProvider.when('/view1', {
            templateUrl: 'view1/view1.html',
            controller: 'View1Ctrl'
        });
}])//controller and factory not shown

查看3

angular.module('myApp.view3', ['ngRoute'])

.config(['$routeProvider', function ($routeProvider) {
        $routeProvider.when('/view3', {
            templateUrl: 'view3/view3.html',
            controller: 'View3Ctrl'
        });
}])

.controller('View3Ctrl', ['$scope', function($scope){

}
]);

對不起,我才意識到我忘了在HTML文件中包含JS腳本

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM