zoukankan      html  css  js  c++  java
  • AngularJS数据绑定中数据监控的机制说明

    from : http://docs.angularjs.org/guide/scope

    When the browser calls into JavaScript the code executes outside the Angular execution context, which means that Angular is unaware of model modifications. To properly process model modifications the execution has to enter the Angular execution context using the $apply method. Only model modifications which execute inside the $apply method will be properly accounted for by Angular. For example if a directive listens on DOM events, such as ng-click it must evaluate the expression inside the $apply method.

    After evaluating the expression, the $apply method performs a $digest. In the $digest phase the scope examines all of the $watch expressions and compares them with the previous value. This dirty checking is done asynchronously. This means that assignment such as $scope.username="angular" will not immediately cause a $watch to be notified, instead the $watch notification is delayed until the $digest phase. This delay is desirable, since it coalesces multiple model updates into one $watch notification as well as it guarantees that during the $watch notification no other $watches are running. If a $watch changes the value of the model, it will force additional $digest cycle.

  • 相关阅读:
    第十一章 表单与验证
    第十章 日期与时间
    第九章 正则表达式
    第八章 字符串处理
    纯C实现面向对象之接口编程
    csharp 面向对象编程
    cpp面向对象编程
    javascriptMVC框架面向对象编程
    堆栈的区别
    Java堆栈简介
  • 原文地址:https://www.cnblogs.com/dhcn/p/7105535.html
Copyright © 2011-2022 走看看