【发布时间】:2014-02-06 09:58:54
【问题描述】:
我有一个很大的 Angular 应用程序,在主页中包含 5 个模板,使用
<script type="text/ng-template" id="/myMainTemplate.html">...</script>
<script type="text/ng-template" id="/myTemplatePage2.html">...</script>
<script type="text/ng-template" id="/myTemplatePage3.html">...</script>
<script type="text/ng-template" id="/myTemplatePage4.html">...</script>
但是,我的应用程序需要很长时间才能启动。
删除模板 2/3/4 修复它,但当然破坏了应用程序,我的猜测是 angularjs 编译 5 个模板需要太多时间。
有没有办法预编译 angularjs 模板,例如使用 nodejs 或类似的东西(也许我们可以用把手编译模板的方法相同)?
如果我很好理解 $compile 指令,我的想法是将指令 $compile(myTemplate) 移动到客户端内部的服务器端
【问题讨论】:
标签: javascript angularjs templates precompile