grunt-angular-templates icon indicating copy to clipboard operation
grunt-angular-templates copied to clipboard

compiled templateCache does not work for directives

Open idododu opened this issue 8 years ago • 3 comments

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

idododu avatar Apr 28 '16 14:04 idododu

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

BenMGilman avatar Jun 07 '16 21:06 BenMGilman

+1

I can confirm the importance of what's in the cache matching exactly to the templateUrl from the directive declaration.

enragedginger avatar Sep 18 '16 13:09 enragedginger

I met with the exactly same issue, any echoes?

hailengc avatar Jan 20 '17 08:01 hailengc