Den*_*hik 5 angularjs angular-templatecache
我正在使用grunts ng-template将html模板存储在$ templateCache中。有角度的文档建议我可以使用如下模板:
myApp.component('myComponent', {
templateUrl: 'templateId.html'
});
Run Code Online (Sandbox Code Playgroud)
或像这样:
myApp.component('myComponent', {
template: $templateCache.get('templateId.html')
});
Run Code Online (Sandbox Code Playgroud)
有什么不同?我并不是很想在每个指令/组件中注入$ templateCache只是为了使用此功能。这是关于性能的吗?
我已经阅读了这篇文章:Angularjs 和templateUrl模板和templateUrl之间的性能差异有多大,如果使用模板(不是templateUrl),速度会更快一些。这是唯一的区别吗?