angularjs:ng-include不在另一个视图中工作

时间:2016-11-04 08:41:21

标签: angularjs angularjs-ng-include

我正在尝试包含一个模板,但它不起作用。我每次尝试使用它时都遇到了麻烦。有什么我做错了吗?

观点结构:

https://i.stack.imgur.com/yFeYs.png

UserList.html:

<p>
    UserList
</p>
<div ng-include src="'../Partials/Paging.html'"></div>

更新:

Paging   : localhost/Administrator/App/Views/User/UserList.html 
UserList : localhost/Administrator/App/Views/Partials/Paging.html 
Index    : localhost/Administrator/Index.html

3 个答案:

答案 0 :(得分:1)

您的包含路径从index.html开始,因为它在运行SPA时从那里加载。 因此,您的包含路径必须与index.html相关:

<div ng-include="'App/Views/Partials/Paging.html'"></div>

答案 1 :(得分:0)

尝试

<div ng-include="'App/Views/Partials/Paging.html'"></div>

ng-include不需要src参数。如果您仍然看到任何错误,请验证Paging.html

的路径

答案 2 :(得分:0)

试试这个

<div ng-include="'../Partials/Paging.html'"></div>

直到你不能获得src路径可能是错误的