$watch
$scope对象上的$watch方法会给Angular事件循环内的每个$digest调用装配一个脏值检查。
如果在表达式上检测到变化, Angular总是会返回$digest循环。
$watch函数本身接受两个必要参数和一个可选的参数:
 watchExpression
watchExpression可以是一个作用域对象的属性,或者是一个函数。在$digest循环中的每
个$digest调用都会涉及它。
如果watchExpression是一个字符串, Angular会在$scope上下文中对它求值。如果它是一个
函数,那么Angular会认为它会返回应该被监控的值。
 listener/callback
作为回调的监听器函数,它只会在watchExpression的当前值与先前值不相等(除了首次运
行初始化期间)时调用。
 objectEquality(可选)
objectEquality是一个进行比较的布尔值,用来告诉Angular是否检查严格相等。
$watch函数会给监听器返回一个注销函数,我们可以调用这个注销函数来取消Angular对当
前值的监控。

$evalAsync vs $timeout

http://stackoverflow.com/questions/17301572/angularjs-evalasync-vs-timeout
To summarize:
if code is queued using $evalAsync from a directive, it should run after the DOM has been manipulated by Angular, but before the browser renders
if code is queued using $evalAsync from a controller, it should run before the DOM has been manipulated by Angular (and before the browser renders) -- rarely do you want this
if code is queued using $timeout, it should run after the DOM has been manipulated by Angular, and after the browser renders (which may cause flicker in some cases)

$apply

http://blog.csdn.net/dm_vincent/article/details/38705099
如果你在AngularJS上下文之外的任何地方修改了model,那么你就需要通过手动调用$apply()来通知AngularJS。这就像告诉AngularJS,你修改了一些models,希望AngularJS帮你触发watchers来做出正确的响应。

随机推荐

  1. dedecms 采集规则过滤与替换

    过滤与替换常用操作:点击"常用规则",选择要过滤的代码段,再编辑成我们需要的.如果会文章简单采集了,接下来就需要过滤掉采集内容中的广告和链接及其它代码.一般的写法是{dede:tr ...

  2. IOS UIAppLocation 单例模式

    UIApplocation * app=[UIApplocation shareapplocation]; UIAppLocation 只能被初始化一次. 一个程序中只能被创建一次,称为单例模式. 单 ...

  3. 测试...外部指针访问private

    #include<iostream> using namespace std; class A{ public: int* getPointer(){ return &m; } v ...

  4. Codeforces CF#628 Education 8 F. Bear and Fair Set

    F. Bear and Fair Set time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  5. Code First 关系配置整理

    之前EF一直有性能问题以及使用便利性问题, 终于到了EF6有了Migrations之后, 小弟也决定加入EF阵营了. 在学习FluentAPI配置关系的时候, 发现网上的好几个教程实际上博主自己都没有 ...

  6. [翻译svg教程]svg中的circle元素

    svg中的<circle> 元素,是用来绘制圆形的,例如 <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink= ...

  7. Yii框架 400 错误

    YII  400错误 在YII框架中400错误是csrf校验失败的意思 csrf是什么? CSRF(Cross-site request forgery跨站请求伪造,也被称为"One Cli ...

  8. 开启PHP的伪静态

    1.检测Apache是否支持mod_rewrite 通过php提供的phpinfo()函数查看环境配置,通过Ctrl+F查找到“Loaded Modules”,其中列出了所有 apache2handl ...

  9. gulp-less解决遇到错误停止执行task

    来龙去脉 在用less+gulp开发时,有时候代码还没写完整,不小心保存了一下,然后gulp就开始执行gulp-less的task. 但是代码是有问题的,这时候会输出一个Potentially unh ...

  10. Android事件分发传递

    一.与触摸事件有关的几个方法 boolean dispatchTouchEvent(MotionEvent ev); 接收到触摸事件时,是否分发事件到下面的View 返回true:分发触摸事件 返回f ...