Router does not load content from $templateCache #162

Open
asgeo1 opened this Issue Apr 7, 2013 · 6 comments

Comments

Projects
None yet
5 participants

asgeo1 commented Apr 7, 2013

I'm trying to use the grunt-angular-templates module to bundle my templates.

https://github.com/ericclemmons/grunt-angular-templates

It will basically generate some code like this:

angular.module('myApp').run([
    '$templateCache',
    function ($templateCache) {
        $templateCache.put('views/test.html', '<p>this is my template content</p>');
    }
]);

But the router in jquery-mobile-angular-adapter will not use the $templateCache, and will always make an ajax request to views/test.html:

angular.module('myApp', []).config([
    '$routeProvider',
    function ($routeProvider) {
        return $routeProvider.when('/test', {
            templateUrl: 'views/test.html',
            jqmOptions: { transition: 'none' }
        })
    }
]);

However using a directive like this in index.html will work:

  <ng-include src="'views/test.html'"></ng-include>

So it's definitely a problem with the router.

Any ideas?

Contributor

tbosch commented Apr 10, 2013

Hi,
right now, the adapter uses jquery mobile to load the pages. By this, we are also using the jquery mobile page cache and not the templateCache of angular.

However, we could override $.mobile.loadPage so that the normal template loading of angular applies....

Have to think about this and am converting this into a feature request.

As a workaround, you could put all your pages into your index.html (e.g. by creating a custom grunt plugin...).

Tobais

tsov commented Apr 29, 2013

Hey, wow, i am happy to find this issue page! I am having issues with this feature too.

I need to load partials from templateCache in order to test them properly (note: i am not using any server side help unfortunately, long story..)

Anyway, if there is any way around this issue, please do let me know

--max

Contributor

tbosch commented May 7, 2013

Right now, the only way is to add your page as internal jqm page into the index.html, maybe in an automatic build step...

Tobias

tsov commented May 7, 2013

well a good way of implementing this feature might be, by checking the templateCache first before using $.mobile.loadPage ?

Same problem here.
Would like to use $templateCache with $routeProvider

envision commented Jul 3, 2015

Having this issue also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment