0

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?

1

1 Answer 1

1
this.someForm.get('firstName').disable(); //not works

should work, you just need to update value and validity afterwards:

this.someForm.get('firstName').updateValueAndValidity();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.