Angular.js with jQuery Mobile

All we need is an easy explanation of the problem, so here it is.

I’m doing an app with jQuery Mobile and Angular.js. Cause we have some issues using both libs, exists an adapter that do “teh job”.

So I’m trying using routeProvider to route my pages. But I still can’t render pages using this.

Here plunker if u can help show me the way.

Thanks in advance!

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

I ran into a similar problem and maybe what I learned might help you. It comes down to the differences in the way angular and jquery go from one page/section to another (routing).

First, the basics: angular routes by inserting a chunk of html into your view, then on whatever click/action/etc, removing that html from the view and adding a new chunk of html. Essentially you’re on the same page all the time; it’s just the included html is changing. In contrast, think of jqm as loading up all the html into the same page, with those html chunks as divs. Instead of removing html chunks and replacing them (via routing), it’s just turning divs off and on. (There are multi-page jqm apps but SPAs really highlight the differences.)

My suggestion is to pick which set of features you really want: angular’s minimalistic loading (only as you need it), or jqm’s flashy transitions and other built-in features. If you’ve got a massive app with a lot of data on every page, you might want to bypass jqm and use angular alone, and see what you can do with angular’s new animate functions. It’ll mean you’ll need to build (via CSS or javascript) duplicates of the jqm features — and from what I’ve seen, you can get close but it won’t quite be as pleasantly streamlined as jqm.

If the jqm built-in features are what you really want, then skip using angular’s routing. It’ll just introduce all kinds of complications, anyway. Set up your pages using jqm’s pattern, and use angular only where you’re dealing with data.

What I’ve found works best is to treat it like it’s a jqm app overall, and only add angular into the sections where you need it. After all, you don’t have to add ng-app at the html line; you can add it into a single div as needed. Since jqm is happiest as a system-wide kind of thing, while angular is just fine being confined to pieces within a system, so far I’ve found jqm-whole and angular-parts to be the simplest way to get the best of both worlds.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply