AngularJs:NG-包括放置在NG-视图标签内不工作时视图、标签、工作、AngularJs

2023-09-14 00:24:24 作者:何必再说何必

我通过NG-视图中角路线加载HTML页面。这我加载该页面包含一个NG-包括标签,指向另一个HTML文件。

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.

我试过下面的语法=

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

无工作。但是如果我把同一个变量在NG-视图之外其工作的罚款。

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

我在做什么错了?

推荐答案

的URL文件应该是相对于你的index.html(主HTML文件)。如果你的结构是这样的:

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

和中的template1要NG-包括template2.html,你应该做的。

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

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

这里是一个工作的例子。