angularjs – 使用ng-include和模板缓存

前端之家收集整理的这篇文章主要介绍了angularjs – 使用ng-include和模板缓存前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在开发角js.以前,我使用ng-include和url.但是我怎么能将url指向templatecache?

<ng-include
  src="string"
  [onload="string"]
  [autoscroll="string"]>
...
</ng-include>

解决方法

模板缓存使用密钥来标识缓存的元素,因此您可以使用密钥.

$templateCache.put('MY KEY','Cached content');

并在HTML中:

<ng-include src="'MY KEY'"></ng-include>

请参阅AngularJS docs for $templateCache.

猜你在找的Angularjs相关文章