ios9下ionic框架报[$rootScope:infdig] 10 $digest() iterations reached. Aborting!的解决办法
升级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全文:
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!的解决办法的更多相关文章
- ubuntu下修改mysql默认字符编码出现的Job failed to start解决办法
ubuntu下修改mysql默认字符编码出现的Job failed to start解决办法 前几天卸掉了用了好多年的Windows,安装了Ubuntu12.04,就开始各种搭环境.今天装好了MySQ ...
- centos 下安装jdk、tomcat 以及tomcat无法从外部访问的解决办法
centos 下安装jdk.tomcat 以及tomcat无法从外部访问的解决办法 原创 2014年08月28日 10:24:33 标签: selinux enforce cent 2223 昨天在c ...
- Ubuntu下安装软件提示无法锁定管理目录(/var/lib/dpkg/)的解决办法
Ubuntu下安装软件提示无法锁定管理目录(/var/lib/dpkg/)的解决办法 在安装软件的时候,有时候提示,无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它? 这是 ...
- MacBook Pro/Air 下使用 linux ubuntu 系统 波浪号“~”变成其他 符号 的完美解决办法
打开终端,输入: sudo su - > /sys/module/hid_apple/parameters/iso_layout sudo su -需要root权限,所以使用前请注意已下载roo ...
- VMware下ubuntu与win8共享文件时/mnt/hgfs目录为空的解决办法
VMware下ubuntu(guest)与win8共享文件时/mnt/hgfs目录为空的解决办法 环境:VMware-player-5.0.2-1031769 + ubuntu13.04 1.安装vm ...
- win7下安装memcached出现failed to install service or service already installed解决办法
安装memcached时总是提示“failed to install service or service already installed”,开始以为是版本问题,就下了好几个不同版本,可还是老问题 ...
- windows平台下编辑的内容传到linux平台出现中文乱码的解决办法
现象说明:在windows下编辑的内容,上传到linux平台下出现中文乱码.如下: 在windows平台编写haha.txt文件,内容如下: 上传到linux平台,出现中文乱码,如下: 基本上面出现的 ...
- 下拉菜单被表单、图片、FLASH挡住的解决办法
设置Flash的参数: <param name="wmode" value="opaque"> <object classid="c ...
- Win10下安装msi程序包时报2503、2502错误问题及其解决办法
Win10系统下安装TortoiseSvn.Node.js时(.msi后缀的安装文件),在点击安装时老是提示2503,2502错误,因此无法安装上. 搜索了下一般都提到是权限不够引起的该问题.但是右键 ...
随机推荐
- 2877: [Noi2012]魔幻棋盘 - BZOJ
DescriptionInput 第一行为两个正整数N,M,表示棋盘的大小. 第二行为两个正整数X,Y,表示棋盘守护者的位置. 第三行仅有一个正整数T,表示棋盘守护者将进行次操作. 接下来N行,每行有 ...
- java 非法字符过滤 , 半角/全角替换
java 非法字符过滤 , 半角/全角替换 package mjorcen.netty.test1; import java.io.UnsupportedEncodingException; publ ...
- C+= concurrent_queue 线程安全测试
更推荐使用:http://www.boost.org/doc/libs/1_56_0/doc/html/boost/lockfree/queue.html #include <include/t ...
- C# 数据结构--排序[下]
希尔排序(Shell Sort) 排序思想: 先取一个小于n的整数d1作为第一个增量,把文件的全部记录分组.所有距离为d1的倍数的记录放在同一个组中.先在各组内进行直接插入排序:然后,取第二个增量d2 ...
- 【BZOJ】【2561】最小生成树
网络流/最小割 对于所有小于L的边求一个割使得U,V不连通,这样就可以保证L可能在最小生成树里. 最大生成树同理. 答案累加一下即可.(Orz Hzwer) (我一开始怎么会sb地去想到一起求呢……) ...
- 【BZOJ】【3524】【POI2014】Couriers
可持久化线段树 裸可持久化线段树,把区间第K大的rank改成num即可……(往儿子走的时候不减少) 苦逼的我……MLE了一次(N*30),RE了一次(N*10)……数组大小不会开…… 最后开成N*20 ...
- MySQL主从关系设置(转)
来源:LAMP兄弟连 作者:李恺 http://***/php/bencandy.php?fid=70&id=635 要做MySQL主从关系的设置,那么就得有两台MySQL主机.所以在开始之前 ...
- POJ2752 Seek the Name,Seek the Fame KMP算法
KMP继续练手.题目问的是一个串前缀等于后缀的可能长度是哪些,输出来.题目考的是对KMP失配指针的理解,当最后一位失配(即'\0'那里)时,指针会移动到前缀对应匹配的部分,所以这个长度是我们要的,然后 ...
- hdu 1242 Rescue(BFS,优先队列,基础)
题目 /******************以下思路来自百度菜鸟的程序人生*********************/ bfs即可,可能有多个’r’,而’a’只有一个,从’a’开始搜,找到的第一个’r ...
- lintcode:strStr 字符串查找
题目: 字符串查找 字符串查找(又称查找子字符串),是字符串操作中一个很有用的函数.你的任务是实现这个函数. 对于一个给定的 source 字符串和一个 target 字符串,你应该在 source ...