desmondlee desmondlee - 4 months ago 40x
AngularJS Question

Using ng-include with template cache

I am developing in angular js. Previously, i use ng-include with url. But how could i point the url to templatecache?



Template cache uses a key for identifying the cached elements, so you can use the key for that.

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

And in the html:

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

See it on AngularJS docs for $templateCache.