Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make dirty or touched input programmatically in Angular2?

I needs to use one jquery plugin with Angular2.In General terms, this plugin creates a copy of a piece of html, which has inputs.When data changes, angular2 rerenders it with all the errors etc.But Jquery must pass data back to angular2 when something changes.I did it through the

ControlGroup.controls['control_id'].updateValue(value,{emitEvent,emitModelToViewChange}).

All is well,data comes.But angular2 input in which jquery passes data doesn't become dirty or touched, but I need it to display errors.How to force the input to be touched or dirty? Thanks in advance.

P.S: I know that all this is bad, but I have no choice

like image 262
Bohdan Kontsedal Avatar asked Dec 07 '25 15:12

Bohdan Kontsedal


1 Answers

There is a pull request to make these properties available https://github.com/angular/angular/pull/7288/files

Currently it is marked
- touched when the input emits the blur event
- changed when the input emits the input event

These events probably vary between different types of input controls.

See also https://github.com/angular/angular/blob/master/modules/angular2/src/common/forms/directives/default_value_accessor.ts

like image 112
Günter Zöchbauer Avatar answered Dec 09 '25 14:12

Günter Zöchbauer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!