Ask a Question
Back to All

Need to load templatecache JS file before hitting the routes so they load from templateCache

So I am using ng-templates to create a $templateCache so that I can server my html partials from the templateCache instead of making XHR requests for them. It will also allow us to browser cache the HTML partials.

Basically, ng-templates create a module for me like the one below;

angular.module('AngTemplates', []).run(['$templateCache', function($templateCache) {
'use strict';

"<div class="hero hero--xl fadeIn"><div class="hero__inner">"

In my apps main module within its config block I am using the following to lazyload my templates module above

//debug: true,
modules: [{
events: true,
name: 'AngTemplates',
files: ['App/ang.templates.js']

Now my issue is that within my $routeProvider, I am trying to do a resolve to load the module, so that that when the code hits my routes because my templateUrl's match those in the templateCache within my module it should load them from the templateCache as opposed to making an XHR request.

I can see the ang.templates.js file being loaded, however it seems like its either not being picked up or its too late in the process.

Is what I am trying to do possible with oclazyload?

Many thanks