Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  45] [ 5]  / answers: 1 / hits: 52602  / 8 Years ago, wed, june 15, 2016, 12:00:00

How do I mark an Angular 2 Control as dirty in my code?



When I do it like this:



control.dirty = true;


I get this error:



Cannot set property dirty of #<AbstractControl> which has only a getter

More From » angular

 Answers
6

You should use the markAsDirty method, like this:



control.markAsDirty();


This will also mark all direct ancestors as dirty to maintain the model.



Docs link


[#61754] Tuesday, June 14, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
grant

Total Points: 169
Total Questions: 96
Total Answers: 98

Location: Cape Verde
Member since Sat, Apr 24, 2021
3 Years ago
;