简体   繁体   English

AngularJs:ng-include放置在ng-view标签内时不起作用

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

I am loading a html page via angular route inside a ng-view. 我正在通过ng-view内的有角度路径加载一个html页面。 The page which I am loading contains a ng-include tag, pointing to another html file. 我正在加载的页面包含一个ng-include标记,指向另一个html文件。

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. 但是,如果我在ng-view之外放置相同的标签,它的工作正常。

What am I doing wrong? 我究竟做错了什么?

The url to the file should be relative to your index.html (main html file). 该文件的URL应该与您的index.html(主html文件)相关。 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 在template1中你想要ng-include template2.html,你应该这样做

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

Here is a working example. 是一个有效的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM