Reputation: 12025
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
Upvotes: 1
Views: 1314
Reputation: 4039
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)])
});
Upvotes: 1
Reputation: 9687
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)]]
})
Upvotes: 1
Reputation:
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]
})
Upvotes: 3