升级ios9后,ionic开发的app会报[$rootScope:infdig] 10 $digest() iterations reached. Aborting!的错误,加上一个patch就可以解决

在index.html里引入js
<script type="text/javascript" src="js/angular-ios9-uiwebview.patch.js"></script>

app.js里加入dependency 'ngIOS9UIWebViewPatch'
angular.module('starter', ['ionic', 'starter.controllers', 'starter.services', 'ngIOS9UIWebViewPatch'])

js/angular-ios9-uiwebview.patch.js的下载地址:
https://gist.github.com/IgorMinar/863acd413e3925bf282c

-----------------------------------------------------------------------------------------------
作者blog:
http://blog.ionic.io/ios-9-potential-breaking-change/
作者blog全文:

iOS 9 Potential Breaking Change

Tweet

 

By Max on September 10, 2015

Update (9/11/2015): A new version of the patch was released by Igor on the Angular team that fixes many issues. Please use it: angular-ios9-uiwebview.patch.js. Make sure to add 'ngIOS9UIWebViewPatch' to your angular modules and use version 1.1.0 or higher of the patch. Also, see our latest postabout other issues that need addressing.

A breaking change was introduced into UIWebView for iOS 9 that could cause issues for apps that heavily rely on the semantics of window.location.

We’ve tested a number of widely-used Ionic apps with iOS 9 beta and GM, and issues appear to be isolated to intermittent UI/navigation issues on some apps, along with console errors indicating infinite digest warnings in Angular. Functionality beyond that should not be impacted.

We are still investigating the impact of this change and working with the Angular team to develop a long-term fix. In the meantime, we’ve (the Angular team has) created a patch to stop the digest issue which was causing the console errors. This hot fix can be included in the majority of Ionic and Angular apps (even those running alpha/beta/rc) releases. If you rely on the semantics of window.location or use the $location service heavily, and have noticed issues on iOS 9 GM please try the patch and let us know how it works for you.

If you do notice an issue with your app in iOS 9, add the patch, and submit your apps for review. There is an openradar issue for this that you might be able to reference to expedite an update (of course, no guarantees). There is supposedly a fix in the works from Apple, but it wasn’t released in time for GM.

Thanks to everyone that has helped us with this issue. If this issue has caused an issue in your app, please let us know (and we are sincerely sorry) as we work towards a permanent fix.

---------------------------------------------------------------------------------------------
---js/angular-ios9-uiwebview.patch.js----------------------------------------------------------------------

/**
* ================== angular-ios9-uiwebview.patch.js v1.1.1 ==================
*
* This patch works around iOS9 UIWebView regression that causes infinite digest
* errors in Angular.
*
* The patch can be applied to Angular 1.2.0 – 1.4.5. Newer versions of Angular
* have the workaround baked in.
*
* To apply this patch load/bundle this file with your application and add a
* dependency on the "ngIOS9UIWebViewPatch" module to your main app module.
*
* For example:
*
* ```
* angular.module('myApp', ['ngRoute'])`
* ```
*
* becomes
*
* ```
* angular.module('myApp', ['ngRoute', 'ngIOS9UIWebViewPatch'])
* ```
*
*
* More info:
* - https://openradar.appspot.com/22186109
* - https://github.com/angular/angular.js/issues/12241
* - https://github.com/driftyco/ionic/issues/4082
*
*
* @license AngularJS
* (c) 2010-2015 Google, Inc. http://angularjs.org
* License: MIT
*/

angular.module('ngIOS9UIWebViewPatch', ['ng']).config(['$provide', function($provide) {
'use strict';

$provide.decorator('$browser', ['$delegate', '$window', function($delegate, $window) {

if (isIOS9UIWebView($window.navigator.userAgent)) {
return applyIOS9Shim($delegate);
}

return $delegate;

function isIOS9UIWebView(userAgent) {
return /(iPhone|iPad|iPod).* OS 9_\d/.test(userAgent) && !/Version\/9\./.test(userAgent);
}

function applyIOS9Shim(browser) {
var pendingLocationUrl = null;
var originalUrlFn= browser.url;

browser.url = function() {
if (arguments.length) {
pendingLocationUrl = arguments[0];
return originalUrlFn.apply(browser, arguments);
}

return pendingLocationUrl || originalUrlFn.apply(browser, arguments);
};

window.addEventListener('popstate', clearPendingLocationUrl, false);
window.addEventListener('hashchange', clearPendingLocationUrl, false);

function clearPendingLocationUrl() {
pendingLocationUrl = null;
}

return browser;
}
}]);
}]);

ios9下ionic框架报[$rootScope:infdig] 10 $digest() iterations reached. Aborting!的解决办法的更多相关文章

  1. ubuntu下修改mysql默认字符编码出现的Job failed to start解决办法

    ubuntu下修改mysql默认字符编码出现的Job failed to start解决办法 前几天卸掉了用了好多年的Windows,安装了Ubuntu12.04,就开始各种搭环境.今天装好了MySQ ...

  2. centos 下安装jdk、tomcat 以及tomcat无法从外部访问的解决办法

    centos 下安装jdk.tomcat 以及tomcat无法从外部访问的解决办法 原创 2014年08月28日 10:24:33 标签: selinux enforce cent 2223 昨天在c ...

  3. Ubuntu下安装软件提示无法锁定管理目录(/var/lib/dpkg/)的解决办法

    Ubuntu下安装软件提示无法锁定管理目录(/var/lib/dpkg/)的解决办法   在安装软件的时候,有时候提示,无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它? 这是 ...

  4. MacBook Pro/Air 下使用 linux ubuntu 系统 波浪号“~”变成其他 符号 的完美解决办法

    打开终端,输入: sudo su - > /sys/module/hid_apple/parameters/iso_layout sudo su -需要root权限,所以使用前请注意已下载roo ...

  5. VMware下ubuntu与win8共享文件时/mnt/hgfs目录为空的解决办法

    VMware下ubuntu(guest)与win8共享文件时/mnt/hgfs目录为空的解决办法 环境:VMware-player-5.0.2-1031769 + ubuntu13.04 1.安装vm ...

  6. win7下安装memcached出现failed to install service or service already installed解决办法

    安装memcached时总是提示“failed to install service or service already installed”,开始以为是版本问题,就下了好几个不同版本,可还是老问题 ...

  7. windows平台下编辑的内容传到linux平台出现中文乱码的解决办法

    现象说明:在windows下编辑的内容,上传到linux平台下出现中文乱码.如下: 在windows平台编写haha.txt文件,内容如下: 上传到linux平台,出现中文乱码,如下: 基本上面出现的 ...

  8. 下拉菜单被表单、图片、FLASH挡住的解决办法

    设置Flash的参数: <param name="wmode" value="opaque"> <object classid="c ...

  9. Win10下安装msi程序包时报2503、2502错误问题及其解决办法

    Win10系统下安装TortoiseSvn.Node.js时(.msi后缀的安装文件),在点击安装时老是提示2503,2502错误,因此无法安装上. 搜索了下一般都提到是权限不够引起的该问题.但是右键 ...

随机推荐

  1. md RAID

    md: mdadm: 将任何块设备做成RAID 模式化的命令:1.创建模式 -C 专用选项: -l: 级别 -n #: 设备个数 -a {yes|no}: 是否自动为其创建设备文件 -c: CHUNK ...

  2. 用matlab查找txt文档中的关键字,并把关键字后面的数据存到起来用matlab处理

    用matlab查找txt文档中的关键字,并把关键字后面的数据存到起来用matlab处理 我测了一组数据存到txt文件中,是个WIFI信号强度文档,里面有我们需要得到的数据,有没用的数据,想用matla ...

  3. 对于WIFI版ipad(无GPS芯片)定位功能的释疑

    把玩ipad(WIFI版ipad,无GPS芯片)很久时间了,曾今有很多人(包括我)也用过它的定位功能,发现它确实很准确,通常的误差在40米以内,所以很多人都怀疑这个版本的ipad是不是真的内置了GPS ...

  4. JAVASCRIPT中的作用域和原型链,应该算是难点了,要好好多学学,练练

    今天初六,要上班啦... JAVASCRIPT,看来是丢不了了.. http://www.dengdeng90.com/wordpress/?p=241 http://www.cnblogs.com/ ...

  5. 为什么Android 3.0如此罕见?

    3.0(2011年2月)代号蜂巢,专用于android系统的平板电脑,不用于手机.4.0(2011年5月公布)的开发就是让平板电脑和手机能够共用一个版本的系统.4.0通用于平板电脑和手机.

  6. hdu2544 最短路

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=2544 最短路径DIJKSTRA #include<stdio.h> #include<m ...

  7. 【mongoDB高级篇①】聚集运算之group,aggregate

    group 语法 db.collection.group({ key:{field:1},//按什么字段进行分组 initial:{count:0},//进行分组前变量初始化,该处声明的变量可以在以下 ...

  8. HTTP会话原理解释与应用

    一.什么是会话 首先解释一下什么是会话.在计算机术语中,会话是指一个终端用户与交互系统进行通讯的过程,比如从输入账户密码进入操作系统到退出操作系统就是一个会话过程.会话较多用于网络上,TCP的三次握手 ...

  9. 使用Maven创建一个Spring MVC Web 项目

    使用Maven创建java web 项目(Spring MVC)用到如下工具: 1.Maven 3.2 2.IntelliJ IDEA 13 3.JDK 1.7 4.Spring 4.1.1 rele ...

  10. cas单点登出

    由于项目需求要实现单点登出需要在网上找了N久终于实现单点登出. 使用cas-server-core-3.3.3.jar(CAS Server 3.3.3) 使用cas-client-core-3.1. ...