AngularJs(1.X)包括部分模板 [英] AngularJs (1.X) Include Partial Template
本文介绍了AngularJs(1.X)包括部分模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经在主布局文件中了
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.
如何在我的应用程序中包含此模板?我认为angular在处理完控制器后会自动包含模板,但这是行不通的.
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-include
指令(
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(1.X)包括部分模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文