【发布时间】:2016-03-28 21:34:29
【问题描述】:
当我们想到在 Angular2 或 Angular1.X 中使用 template 时,我们知道下面是一种基本的写法:
template: './template-ninja.html'
在 Angular1.X 中,我们之前可以缓存所有带有 $templateCache.put() 的模板,如下所示:
var myApp = angular.module('Ninja', []);
myApp.run(function($templateCache) {
$templateCache.put('templateNinja.html', 'This is the content of the template-ninja');
});
这将减少http请求的数量。 我想知道如何使用 Angular2 实现相同的功能。有人可以帮忙吗? 谢谢。
【问题讨论】:
标签: angular