2016-10-27 4 views
0

AngularJSでは、データバインディングを使用してビューに即時データを公開します。 これはオブジェクトスコープwhich is the glue between the Logic CodeThe Viewのためです。 AngularJsがトウ・ウェイ・バインディングをサポートしていることもわかっています! 私の質問は:オブジェクトスコープの入手方法更新プログラムを入手し、ビューに公開する準備をするAngularJs

How the $scope can know that there object binding was changed or not?? 
if there while condition inside scope for auto-change detect or what? 
+1

http://stackoverflow.com/questions/9682092/how-does-data-binding-work-in-angularjs – Ronnie

+0

ありがとう男^ _ ^ – UserStack2255222555

答えて

0

チェックangular.jsファイルは、我々はngBindDirectiveのコードを取得します:

var ngBindDirective = ['$compile', function($compile) { 
    return { 
    restrict: 'AC', 
    compile: function ngBindCompile(templateElement) { 
     $compile.$$addBindingClass(templateElement); 
     return function ngBindLink(scope, element, attr) { 
     $compile.$$addBindingInfo(element, attr.ngBind); 
     element = element[0]; 
     scope.$watch(attr.ngBind, function ngBindWatchAction(value) { 
      element.textContent = isUndefined(value) ? '' : value; 
     }); 
     }; 
    } 
    }; 
}]; 

注最後の2行を、それが変更のために、属性ngBindためウォッチャーを使用して要素に適用されます。

関連する問題