I have my template preloaded into a javascript string array, for example var t = JST['firstTemplate'], where it twill look,
<div>This scope has a value of {{value}}</div>
How to use this preloaded template in the directive ng-include?
Please note that my template in this scenario can be more complex, with possible nested representation and templates and their own nested areas and controllers. So, I'm not sure if any of the ng-bind directives helped?
UPDATE:
Looking at the source ng-include, it seems like a good way to do this would be to untie the logic of loading the template into a custom provider.
Current default download mechanism simply performs $http.getwith $templateCacheas a provider cache. It looks like I can add the contents of a template to the template JST['firstTemplate']cache, but I would have to do this at startup time for each template.
$templateCache.put('firstTemplate', JST['firstTemplate']);
and then,
<div ng-include="firstTemplate"></div>
I could also write a custom directive that goes side by side with every ng-include that somehow does this pre-caching of templates. This again seems awkward.
UPDATE # 2
I'm going to try to override templateCache so that it uses my already preloaded JST hash. The result will be published if this is done.
source
share