Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Mobile vs AngularJs page navigation

I am developing a hybrid mobile app using jQuery Mobile and AngularJS.

I decided to use a mix of the two for the following:

  1. jQuery Mobile
    • good UI features
    • not too heavyweight (compared to Sencha Touch, for example)
  2. AngularJS
    • good performance and resource management (caching, asynchronous requests)
    • personal experience

I have little to no experience with jQuery Mobile and, as I was learning, I noticed a potential conflict between the page navigation models of the two.

  1. Should I use only one ?
  2. If yes, which one is better suited for my needs ?
  3. Are there any gotchas with this setup ?

Many thanks.

like image 681
Radu Stoenescu Avatar asked Sep 16 '13 12:09

Radu Stoenescu


1 Answers

You can't compare them to each other.

Angular.js (like Backbone, Ember eg.) are MV* Frameworks (for SPA) which used to render html templates/views directly in the client instead of server. So you have a lot of application logic now in your frontend and this Frameworks are made to make your life better, coding this.

jQuery Mobile on the other side is a pure widget/plugin library. The AJAX navigation plugin load pages (something static, like html) into the DOM via AJAX. So you have to pre-render this pages on the server somehow. If you started to build a SPA with Angular it doesn't make sense to use jQuery Mobile's AJAX navigation at all. (If it's a native mobile app you have no server anyway.)

Sure, you won't get far without an UI component library so use one of your choice (eg. jQM) but work with Angular's directives to init the plugins/widgets correctly on your DOM elements since a $(document).ready(...) or a $(document).on( "pageload", ... ) doesn't know anything about your Angular views. Take a look at following projects: http://angular-ui.github.io https://github.com/angular-widgets/angular-jqm

like image 110
SergeL Avatar answered Oct 13 '22 10:10

SergeL