AngularJs: ng-include not working when placed inside a ng-view tag

耗尽温柔 提交于 2020-02-02 04:23:45

问题


I am loading a html page via angular route inside a ng-view. The page which I am loading contains a ng-include tag, pointing to another html file.

I tried all the below syntax =

<div ng-include src="'some.jsp'"></div>
<div ng-include="'login.jsp'"></div>
<div ng-include src="include.url"></div>

None working. But If I put the same tag outside the ng-view its working fine.

What am I doing wrong?


回答1:


The url to the file should be relative to your index.html (main html file). If your structure is like this:

index.html
template
    template1.html
    template2.html

and in template1 you want to ng-include template2.html, you should do

<div ng-include="'template/template2.html'"></div>

Here is a working example.



来源:https://stackoverflow.com/questions/24059749/angularjs-ng-include-not-working-when-placed-inside-a-ng-view-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!