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
指令(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 (1.X) 包含部分模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文