How to observe touched event on Angular 2 NgForm?

后端 未结 4 1868
青春惊慌失措
青春惊慌失措 2020-12-18 18:53

It is possible to subscribe a callback to an NgForm\'s valueChanges observable property in order to react to changes in the values of the controls

4条回答
  •  佛祖请我去吃肉
    2020-12-18 19:36

    There is not direct way provided by ng2 to react on touched event. It uses (input) event to fire the valueChanges event and (blur) event to set touched/untouched property of AbstractControl. So you need to manually subscribe on desired event in the template and handle it in your component class.

提交回复
热议问题