Watch controller model value from inside directive

前端 未结 4 405
天命终不由人
天命终不由人 2020-12-13 04:57

I am trying to have angular watch the $viewValue of a controller from inside a directive.

fiddle: http://jsfiddle.net/dkrotts/TfTr5/5/

f         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 05:33

    If you want debounce on a model value, it is worth mentioning the debounce setting in ng-model-option:

    
    

    For example: this watch is trigger 1000 ms after change and reset at new changes.

    scope.$watch(attrs.ngModel, function(newValue) { });
    

    https://docs.angularjs.org/api/ng/directive/ngModelOptions

提交回复
热议问题