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

标签 javascript html angularjs angularjs-ng-include ng-view

我正在通过 ng-view 中的 Angular 路径加载 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 之外 它工作正常。

我做错了什么?

最佳答案

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

index.html
template
    template1.html
    template2.html

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

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

Here是一个工作示例。

关于javascript - AngularJs:当放置在 ng-view 标签内时,ng-include 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24059749/

相关文章:

javascript - 如何构建长度转换器

javascript - 菜单打开和关闭菜单按钮 - Jquery

html - 将带有重叠图像的 div 放在底部

javascript - Angular 在注入(inject)的 cshtml 文件中,$compile 不起作用

javascript - jquery 和更新面板?

javascript - Paypal Checkout 集成 - onShippingChange 不适用于新的 SDK

javascript - 如何居中div?

html - CSS 弄乱了 eBay 列表?

javascript - 如何在 AngularJS 中链接两个 http 调用?

angularjs - Asp.net core中的SPA预渲染?