4

我正在通过 ng-view 中的角度路径加载 html 页面。我正在加载的页面包含一个 ng-include 标记,指向另一个 html 文件。

我尝试了以下所有语法=

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

没有工作。但是,如果我将相同的标签放在 ng-view 之外,它的工作正常。

我究竟做错了什么?

4

1 回答 1

7

该文件的 url 应该与您的 index.html(主 html 文件)相关。如果你的结构是这样的:

index.html
template
    template1.html
    template2.html

在你想要 ng-include template2.html 的 template1 中,你应该这样做

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

是一个工作示例。

于 2014-10-25T13:21:16.837 回答