AngularJs包括部分模板 [英] AngularJs Include Partial Template
本文介绍了AngularJs包括部分模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的主要布局文件在这篇
I've this in my main layout file
<body>
<header id="header" ng-controller="HeaderController"></header>
<div class="container" ng-view></div>
我在目录结构中倒真了header.html局部模板。
I've a header.html partial template in my directory structure.
如何纳入我的应用程序这个模板?我以为角度自动包括处理控制器后的模板,但它不工作。
How to include this template in my app? I thought angular automatically includes the template after processing the controller, but it doesnt work.
头节点应与该文件的内容来代替。
The header node should be replaced with the content of this file.
推荐答案
包括来自外部文件模板/ HTML片段的方法之一是使用 NG-包括
指令( DOC )。
One way of including templates/html fragments from external files is to use the ng-include
directive (doc).
<ng-include src="'/path/to/the/header.html'"></ng-include>
或
<div ng-include src="'/path/to/the/header.html'"></div>
这篇关于AngularJs包括部分模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文