如何使用Angular JS作为模板引擎?

时间:2022-02-02 14:30:08

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?

但是,如果我想将页面加载similair上的模板部分加载到像Smarty这样的模板引擎呢?

For example in Smarty:

例如在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>

1 个解决方案

#1


9  

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

您可以使用ngInclude指令。文档和示例可以在这里找到:http://docs.angularjs.org/api/ng.directive:ngInclude

#1


9  

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

您可以使用ngInclude指令。文档和示例可以在这里找到:http://docs.angularjs.org/api/ng.directive:ngInclude