Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiled templateCache does not work for directives #161

Open
idododu opened this issue Apr 28, 2016 · 3 comments
Open

compiled templateCache does not work for directives #161

idododu opened this issue Apr 28, 2016 · 3 comments

Comments

@idododu
Copy link

idododu commented Apr 28, 2016

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

@BenMGilman
Copy link

BenMGilman commented Jun 7, 2016

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

@enragedginger
Copy link

+1

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

@hailengc
Copy link

hailengc commented Jan 20, 2017

I met with the exactly same issue, any echoes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants