grunt-angular-templates
grunt-angular-templates copied to clipboard
compiled templateCache does not work for directives
compiled template cache does not work, it still send additional http request to get template. Can anyone help?
Here is an example of a directive:
navigation.js
app.directive('navigation', function() {
return {
restrict: 'E',
templateUrl: 'src/components/navigation.html',
controller: 'NavigationController as navCtrl'
};
})
templates.js (compiled via grunt-angular-templates)
angular.module('app').run(['$templateCache', function($templateCache) {
$templateCache.put('src/components/navigation.html', '<nav>Nav here</nav>'
// Other templates here too
);
http://stackoverflow.com/questions/32615698/angularjs-templatecache-for-directive-templates-via-grunt-plugin
I ran into the same issue. For me, though, the issue was what I had in my templateUrl
vs what was in template cache. For example, my directives had /src/components/navigation.html
, while my template cache was put in as src/components/navigation.html
. Make sure your file paths match up exactly
+1
I can confirm the importance of what's in the cache matching exactly to the templateUrl from the directive declaration.
I met with the exactly same issue, any echoes?