【发布时间】:2022-11-24 16:40:00
【问题描述】:
下面指定的是我的数据
Id , Name , IsBillable
1 One 1
2 two 0
3. three 0
这将是下面的下拉值我将分享 html 下拉代码
<mat-option *ngFor="let option of masterAppointmentTypes" [value]="option.id">
{{option.value}}
</mat-option>
上面的 html 有效。我需要做的就是:在下面的代码中获取 IsBillable 数据
if(this.appointmentForm.get('id').value == this.appointmentForm.get('id').value && this.appointmentForm.get('IsBillable').value){
this.openPaymentDialog(appointmentData, queryParams)
}
else{
this.createAppointment(appointmentData, queryParams);
}
在上面的代码中,我根据所选的下拉列表获取了 ID 值,但我没有根据所选的 id 获取 IsBillable 数据。下面的代码是我的 formBuilder。
const configControls = {
'AppointmentTypeID': [appointmentObj.appointmentTypeID, Validators.required],
'IsBillable' : [appointmentObj.isBillable,Validators.required],
}
this.appointmentForm = this.formBuilder.group(configControls);
【问题讨论】:
-
你在使用角材料
mat-select吗?如果是这样,就有selectionChangematerial.angular.io/components/select/api。(selectionChange)="callSomeFunction($event)"
标签: angular