javascript - ng-include and $templateCache -


currently working on big html file(7k+ lines of code). have refactor whole thing. person responsible code using method presented below load specific templates cache used via ng-include.

<script type="text/ng-template" id="app/templates/example.html">     <p>example</p> </script> 

those templates exist separate html files.

my first idea use

$templatecache.put(url,content) 

method during module.run() stage. perfect solution, if somehow pass template-url-path second parameter(content) instead of passing actual html code.

or perhaps should add templates via directive.templateurl ?

thank in advance!

unless important have templates cached once app loads place templates own files , put templateurl on directives or routes.

edit:


angular call template once during lifespan of application when particular route or directive loads, , after angular go $templatecache service. if specify templateurl on directive, once directive loads first time angular ajax call template , store in $templatecache you. having 100 directives on page use templateurl of views/user.html call template once , never again until page reloads.


if using grunt-angular-templates or gulp-angular-templatecache dan said option go that, production builds.

keep in mind though when using grunt-angular-templates, if have directive references templateurl /views/main.html , have views/main.html loaded $templatecache, angular won't know use default because it's missing leading slash.


Comments

Popular posts from this blog

javascript - three.js lot of meshes optimization -

smartface.io - Proper way to change color scheme for whole application -

Email notification in google apps script -