【发布时间】:2017-07-18 15:18:26
【问题描述】:
我已经阅读了 $templateCache 的文档,但我仍然难以理解如何使用 put 函数将远程模板加载到缓存中。
下面是一个例子:
onBoardingApp.run(function ($templateCache, $http) {
$templateCache.put('tpl1.html', '<p>Hello World</p>');
$templateCache.put('tpl2.html', '~/Templates/Pi/pi-1.html');
alert($templateCache.get('tpl1.html'));
alert($templateCache.get('tpl2.html'));
});
虽然我的代码返回 tpl1 的 HTML 代码,但正在返回 tpl2 的路径。我的问题是:如何使用 $templatecache.put() 加载远程模板。
感谢您的帮助。
【问题讨论】:
标签: angularjs caching angular-templatecache