问题
I'm trying to disable an element of my formbuilder after the declaration because I have to validate something once my view is loaded, so this is my formBuilder declaration.
ionViewDidLoad() {
this.purchaseDataForm = this.formBuilder.group({
kms: ['', Validators.required],
lts: ['', Validators.required],
price: ['', Validators.required],
total: ['', Validators.required]
});
}
I have no idea how to do that because I want to disable the total
element once finished my local validation. I hope you can help me.
Thanks!
回答1:
this.purchaseDataForm.get('price').disable() // .enable()
See also https://angular.io/docs/ts/latest/api/forms/index/AbstractControl-class.html#!#disable-anchor
来源:https://stackoverflow.com/questions/40792392/angular2-disable-a-formbuilders-element