Reputation: 152
What I'm trying to achive is after initiation of the form to disable some controls;
this.someForm= this._fb.group({
lastName: ['', Validators.required],
firstName: ['', Validators.required]
});
<input type="text" formControlName="firstName" class="input-field"/>
this.someForm.controls.firstName.disable(); //not works
this.someForm.get('firstName').disable(); //not works
Is there a way to do that without recreating form?
Upvotes: 0
Views: 111
Reputation: 1499
this.someForm.get('firstName').disable(); //not works
should work, you just need to update value and validity afterwards:
this.someForm.get('firstName').updateValueAndValidity();
Upvotes: 1