如何使用角度JS作为模板引擎? [英] How do I use Angular JS as a templating engine?

查看:152
本文介绍了如何使用角度JS作为模板引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<一个href=\"http://stackoverflow.com/questions/12346690/is-there-a-way-to-make-angularjs-load-partials-in-the-beginning-and-not-at-when\">post进入细节如何绑定的事件装载模板谐音。

但是,如果我想在页面加载的负载模板谐音 similair像Smarty的模板引擎?

什么

例如在Smarty的:

 &LT; HTML和GT;
&LT;身体GT;
{包括文件=模板/ header.html中}
&LT;跨度&GT;好家伙,这也有可能在角JS ...&LT; / SPAN&GT;
{包括文件=模板/ footer.html}
&LT; /身体GT;
&LT; / HTML&GT;


解决方案

您可以使用ngInclude指令。该文档和例子可以在这里找到:<一href=\"http://docs.angularjs.org/api/ng.directive:ngInclude\">http://docs.angularjs.org/api/ng.directive:ngInclude

This post goes into detail how to bind loading template partials on events.

But what if I wanted to load template partials on page load similair to a templating engine like Smarty?

For example in Smarty:

<html>
<body>
{include file="templates/header.html"}
<span>Dude, this has too be possible in Angular JS...</span>
{include file="templates/footer.html"}
</body>
</html>

解决方案

You can use the ngInclude directive. The documentation and an example can be found here: http://docs.angularjs.org/api/ng.directive:ngInclude

这篇关于如何使用角度JS作为模板引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆