简体   繁体   English

jQueryMobile路由不适用于AngularJS

[英]jQueryMobile routing not working with AngularJS

I'm writing a mobile web app with jQueryMobile and I put in AngularJS to handle data binding. 我正在用jQueryMobile编写一个移动Web应用程序,并放入AngularJS来处理数据绑定。 But this introduces routing problems on mobile devices. 但这引入了移动设备上的路由问题。 Below is the minimal code I could write to reproduce the problem. 下面是我可以编写以重现该问题的最少代码。 Everything works OK on Chrome on desktop, but when I try the same page from my android device I get the nasty "Error loading page". 在台式机上的Chrome浏览器上一切正常,但是当我在Android设备上尝试访问同一页面时,会收到讨厌的“错误加载页面”。 Problem can be fixed by using data-url for navigation but there's catch. 可以通过使用data-url进行导航来解决问题,但存在问题。 I also need to package it up with phone gap. 我还需要将其与手机间隙包装在一起。 This means html is loaded by file:// and direct navigation(data-url) doesn't work(I tried) 这意味着html由file://加载,并且直接导航(data-url)不起作用(我尝试过)

<!DOCTYPE html>
<html ng-app>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
        <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
        <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>

        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>

        <script src="https://raw.github.com/tigbro/jquery-mobile-angular-adapter/master/compiled/jquery-mobile-angular-adapter-1.2.0.js"></script>        
    </head>

    <body>
        <div data-role="page" id="main">
            <a data-role="button" href="#sub">sub</a>
        </div>

        <div data-role="page" id="sub">
            <p>sub page</p>
        </div>
    </body>

</html>

Upon clicking the "sub" button user should be directed to hostname/#sub and it is on Chrome but weird things happen on android and browser is routed to hostname/#!/%23sub I guess this is URL encoded? 单击“ sub”按钮后,应该将用户定向到主机名/#sub,它在Chrome上,但是奇怪的事情在android上发生,浏览器路由到主机名/#!/%23sub,我想这是URL编码吗?

Also I should point out that by removing just the two script refenrences for angular and for JQM-angular adapter everything works(and no databinding of course). 我还要指出,通过仅删除angular和JQM-angular适配器的两个脚本防护,一切正常(当然也没有数据绑定)。

i tried removing angular-jquery adapter and everything works as if by magic. 我试着删除angular-jquery适配器,并且一切正常,就好像靠魔术一样。 also no issues with angular and jquery clashing. 角度和jQuery冲突也没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM