这是ng-include在ng-view输出中的结果:

当然,我只需要加载这个页面一次。
我的app.js:
var app = angular.module('app', ['ngRoute']);
app.config(function($routeProvider, $locationProvider) {
$routeProvider
.when('/first_route', {
templateUrl: '/templates/first/index.html',
controller: 'FirstController',
controllerAs: 'First',
})
.when('/second_route', {
templateUrl: '/templates/second/index.html',
controller: 'SecondController',
controllerAs: 'Second',
});
// I omitted my app.run(), because it contains only headers and redirect to
// login page for not authenticated users
};在我的主index.html文件中,我只使用ng-view指令。
我的first/index.html包含:
<h1>Current page</h1>
<ng-include src="'first/show.html'"></ng-include>
// remaining part of page我的first/show.html包含:
<ng-include src="'second/index.html'"></ng-include>简历:我尝试按下面的顺序加载模板:
index.html (ng-view)first/index.html(ng-include)first/show.html(ng-include)如何解决这个问题?
发布于 2015-12-19 19:51:46
我解决了问题。
问题在不正确的路径上,因此,当ng-include找不到模板时,它就会无限地加载自己。
发布于 2016-07-29 11:18:18
对于可能有类似问题的人,请确保first/index.html和first/show.html包含您想要显示的内容(而不是空页),否则您也可能有与上面相同的循环!
https://stackoverflow.com/questions/34373059
复制相似问题