opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

Router does not load content from $templateCache #162

Open asgeo1 opened 11 years ago

asgeo1 commented 11 years ago

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?

tbosch commented 11 years ago

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 11 years ago

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

tbosch commented 11 years ago

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 11 years ago

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

pstephenwille commented 10 years ago

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

ux-engineer commented 9 years ago

Having this issue also