1

How to disable this formControl:

this.step1 = this.fb.group({
      'name': ['', [Validators.required, Validators.minLength(1), Validators.maxLength(50)], disabled: true]...

I tried to add:

disabled: true

3 Answers 3

3

I'm not sure this works

'name': [{
  value: '',
  disabled: true
}, [Validators.required, Validators.minLength(1), Validators.maxLength(50)], disabled: true]

But I am sure this does

'name': new FormControl([{
  value: '',
  disabled: true,
  validators: [Validators.required, Validators.minLength(1), Validators.maxLength(50)], disabled: true]
})
Sign up to request clarification or add additional context in comments.

Comments

1

You must add that to formState - 1st parameter of fb.control:

this.step1 = this.fb.group({
  'name': this.fb.control({value: '', disabled: true}, [Validators.required, Validators.minLength(1), Validators.maxLength(50)])
});

Comments

1

use disabled:true for this.

this.step1 = this.fb.group({
      name: [{value:'name',disabled:true}, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]],
      lastname: [{value:'last name',disabled:true}, [Validators.required, Validators.minLength(1), Validators.maxLength(50)]]
})

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.