$digest: function() {
var watch, value, last,
watchers,
length,
dirty, ttl = TTL,
next, current, target = this,
watchLog = [],
logIdx, logMsg, asyncTask; beginPhase('$digest');
// Check for changes to browser url that happened in sync before the call to $digest
$browser.$$checkUrlChange(); if (this === $rootScope && applyAsyncId !== null) {
// If this is the root scope, and $applyAsync has scheduled a deferred $apply(), then
// cancel the scheduled $apply and flush the queue of expressions to be evaluated.
$browser.defer.cancel(applyAsyncId);
flushApplyAsync();
} lastDirtyWatch = null; do { // "while dirty" loop
dirty = false;
current = target; while (asyncQueue.length) { //先跑$eval
try {
asyncTask = asyncQueue.shift();
asyncTask.scope.$eval(asyncTask.expression, asyncTask.locals);
} catch (e) {
$exceptionHandler(e);
}
lastDirtyWatch = null;
} traverseScopesLoop:
do { // "traverse the scopes" loop
if ((watchers = current.$$watchers)) {
// process our watches
length = watchers.length;
while (length--) {
try {
watch = watchers[length];
// Most common watches are on primitives, in which case we can short
// circuit it with === operator, only when === fails do we use .equals
if (watch) {
if ((value = watch.get(current)) !== (last = watch.last) &&
!(watch.eq
? equals(value, last)
: (typeof value === 'number' && typeof last === 'number'
&& isNaN(value) && isNaN(last)))) {
dirty = true;
lastDirtyWatch = watch;
watch.last = watch.eq ? copy(value, null) : value;
watch.fn(value, ((last === initWatchVal) ? value : last), current);
if (ttl < 5) {
logIdx = 4 - ttl;
if (!watchLog[logIdx]) watchLog[logIdx] = [];
watchLog[logIdx].push({
msg: isFunction(watch.exp) ? 'fn: ' + (watch.exp.name || watch.exp.toString()) : watch.exp,
newVal: value,
oldVal: last
});
}
} else if (watch === lastDirtyWatch) {
// If the most recently dirty watcher is now clean, short circuit since the remaining watchers
// have already been tested.
dirty = false;
break traverseScopesLoop;
}
}
} catch (e) {
$exceptionHandler(e);
}
}
} // Insanity Warning: scope depth-first traversal
// yes, this code is a bit crazy, but it works and we have tests to prove it!
// this piece should be kept in sync with the traversal in $broadcast
if (!(next = ((current.$$watchersCount && current.$$childHead) ||
(current !== target && current.$$nextSibling)))) {
while (current !== target && !(next = current.$$nextSibling)) {
current = current.$parent;
}
}
} while ((current = next)); // `break traverseScopesLoop;` takes us to here if ((dirty || asyncQueue.length) && !(ttl--)) {
clearPhase();
throw $rootScopeMinErr('infdig',
'{0} $digest() iterations reached. Aborting!\n' +
'Watchers fired in the last 5 iterations: {1}',
TTL, watchLog);
} } while (dirty || asyncQueue.length); clearPhase(); while (postDigestQueue.length) {//最后跑$timeout
try {
postDigestQueue.shift()();
} catch (e) {
$exceptionHandler(e);
}
}
},

angular digest 会先跑 $browser.$$checkUrlChange();, 其他的我带过,接着就是check dirty 和 asyncQueue.length。 最后是check postDigestQuese.length

angular : $eval & $timeout的更多相关文章

  1. .Net Core Web Api实践(四)填坑连接Redis时Timeout performing EVAL

    前言:前两篇文章.net core+Redis+IIS+nginx实现Session共享中,介绍了使用Microsoft.Extensions.Caching.Redis实现Session共享的方法, ...

  2. ASP.NET MVC Html.BeginForm 设置 timeout

    示例代码: @using (Html.BeginForm("PublishSubmit", "Blog", FormMethod.Post, new { id ...

  3. tomcat 504 gateway time-out

    今天有个环境ajax调用一个请求的时候,出现一个504 gateway time-out响应,原以为是nginx找不到资源的问题,恰当我们的服务器上又配置了nginx,看了配置文件,没有指向tomca ...

  4. mysql timeout知多少

    1.timeout变量知多少 打开mysql,用show variables like '%timeout%'命令一看,不看不知道,一看吓一跳,结果如下面所示,这么多timeout相关变量,一下就吓尿 ...

  5. angularjs 中的setTimeout(),setInterval() / $interval 和 $timeout

    $interval window.setInterval的Angular包装形式.Fn是每次延迟时间后被执行的函数. 间隔函数的返回值是一个承诺.这个承诺将在每个间隔刻度被通知,并且到达规定迭代次数后 ...

  6. shiro session计算timeout

    /** * Determines if this session is expired. * * @return true if the specified session has expired, ...

  7. adb connect 出现timeout的处理方式

    默认的timeout是5000ms毫秒,如果是断点调试的时候,经常会出现timeout, 所以修改这个值就不会出现timeout了, Eclipse下的设置位置: Window->Prefere ...

  8. 更改pip安装源的镜像解决安装总是timeout的情况

    由于国外的pip源总是由于各种原因不能被访问或者网速过慢,而造成的timeout错误 解决方法是修改pip的配置文件(如果没有配置文件在相应的地方新建,配置文件的路径和名字参考这里),设置安装包时候访 ...

  9. 初识Angular

    一.AngularJs简介 1.AngularJS使用了不同的方法,它尝试去补足HTML本身在构建应用方面的缺陷.AngularJS通过使用我们称为标识符(directives)的结构,让浏览器能够识 ...

  10. 【异常】No ManagedConnections available within configured blocking timeout

    Caused by: org.jboss.util.NestedSQLException: No ManagedConnections available within configured bloc ...

随机推荐

  1. SQL数据库文件修复/用友/金蝶/管家婆/速达/思讯数据库恢复 硬盘恢复

    硬盘的故障情况可以分为以下几类: 1.控制电路故障 大部分外电路的问题是电源芯片或主轴驱动芯片烧坏引起的,由于硬盘电路板质量问题.设计缺陷.市电波动.突然断电.芯片老化或者散热不良.静电等原因造成芯片 ...

  2. 英文版Ubuntu安装配置搜狗拼音输入法

    下载搜狗输入法 1 进入搜狗输入法官网,进入上面导航兰的 "输入法Linux版"   2 根据你安装的ubuntu是32位还是64位下载 END ubuntu安装搜狗输入法 1 进 ...

  3. Centos下关于ssh、scp与rsync设置与应用

    最近应公司要求,需要对文件数据进行远程传输与备份操作,特此写了一篇文章记录下了关于ssh.scp以及rsync的应用配置全过程,可能过程太过罗嗦,但主要就是想在不遗漏每个过程的情况下对此进行阐述,希望 ...

  4. python 自动化运维项目_目录

    微信小程序监控界面 CMDB 跳板机 代码上线系统 网站用户访问质量监测 分布式监控 Docker自动化管理平台 Openstack二次开发

  5. 文字在div中水平和垂直居中的的css样式

    文字在div中水平和垂直居中的的css样式 text-align:center; /*水平居中*/ line-height: 20px; /*行距设为与div高度一致*/ 示例如下: HTML元素 & ...

  6. Boost.Asio技术文档

    Christopher Kohlhoff Copyright © 2003-2012 Christopher M. Kohlhoff 以Boost1.0的软件授权进行发布(见附带的LICENSE_1_ ...

  7. Eclipse安装git

    用Eclipse开发,如果需要团队协作,git作为分布式版本管理工具就是个比较好的选择.下面简单介绍一下git插件的安装方法: 1.Help -- install new software 打开插件安 ...

  8. python中将两个list合并为字典

    两个list合并为字典的代码如下: def Run(): list2 = [1, 2, 3, 4, 5 ]; list3 = ["a", "b", " ...

  9. 【长 PI】

    /* 长 PI 说明: 圆周率后的小数位数是无止境的,如何使用电脑来计算这无止境的小数是一些数学家与程式设计师所感兴趣的,在这边介绍一个公式配合 大 数运算,可以计算指定位数的圆周率. 解法 : 首先 ...

  10. B树的查找、插入、删除(附源代码)

    B-Tree Index B-Tree搜索 B-Tree插入 分裂节点 插入节点 B-Tree删除 合并节点 删除节点 Basic B-Tree有两个比较重要的性质: 所有的leaf均在同一个leve ...