AngularJS 1.5+ Components do not support Watchers, what is the work around?

前端 未结 7 1235
广开言路
广开言路 2020-11-22 09:23

I\'ve been upgrading my custom directives to the new component architecture. I\'ve read that components do not support watchers. Is this correct? If so how do you detect cha

7条回答
  •  滥情空心
    2020-11-22 09:38

    A small heads-up regarding the use of ng-change, as recommended with the accepted answer, together with an angular 1.5 component.

    In case you need to watch a component that ng-model and ng-change do not work, you can pass the parameters as:

    Markup in which component is used:

    
    
    

    Component js:

    angular
      .module('myComponent')
      .component('myComponent', {
        bindings: {
          onChange: '&',
          fieldValue: '='
        }
      });
    

    Component markup:

    
    

提交回复
热议问题