jQuery Mobile vs AngularJs page navigation

南楼画角 提交于 2019-12-18 13:19:29

问题


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.


回答1:


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




回答2:


This has been already addressed in HERE

Basically the article states that trying to intercept the navigation from angular can be painful, so leave all the routing jqm



来源:https://stackoverflow.com/questions/18827570/jquery-mobile-vs-angularjs-page-navigation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!