Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

set invalid invalid form control in angular2

Is it possible to set as invalid form control in angular2? (used form builder)

eg. i have form-> exampleFrom & field-> exampleControl

I have tried this, not succeed :

this.exampleFrom.controls['exampleControl'].invalid 
like image 675
Ketan Akbari Avatar asked May 08 '17 12:05

Ketan Akbari


1 Answers

Try

let control = this.exampleFrom.controls['exampleControl'];
control.setErrors({backend: {someProp: "Backend message"}});
let message = control.errors['backend'].someProp;
like image 126
A. Tim Avatar answered Nov 03 '22 22:11

A. Tim