所以我在Angular repo中发现了这个问题,他们要求相同,即Angular 2中templateCache的替代方案,但他们关闭它说你可以使用CachedResourceLoader。
所以我的问题是如何使用这个 CachedResourceLoader 来替换 templateCache,我一直在谷歌上搜索这个但找不到任何相关的内容,所以也许我没有指向正确的方向或者我错过了一些东西。
这个问题的答案可能是其他 2 个类似问题的有效答案。
AngularJS 中 templateCache 提供的功能的代码示例:
添加:
var myApp = angular.module('myApp', []);
myApp.run(function($templateCache) {
$templateCache.put('templateId.html', 'This is the content of the template');
});
通过 $templateCache检索:
$templateCache.get('templateId.html')
或检索:
myApp.component('myComponent', {
templateUrl: 'templateId.html'
});