angular - 设置选项后启用选择控制以选择上一个
问题描述
我有一个带有Select控件的表格,在选择该控件时,应禁用相应的控件:
尝试将标志初始化为 false,并在执行 onChange 方法时将其更改为 true,但它仍然不起作用。我留下一些代码:
<div class="form-group">
<div class="form-row">
<div class="col-md-6">
<label>AREA DE SERVICIO*</label>
<select (change)="cargaSelectTipoReclamo()" formControlName="areaServicio" class="form-control" placeholder="Seleccione Area de Servicio">
<option value="" disabled>Seleccione Área de Servicio...</option>
<option *ngFor="let item of arrArServ" [value]="item.arServ_IDAreaServicio">
{{ item.arServ_nombre }}
</option>
</select>
</div>
<div class="col-md-6">
<label>RECLAMO*</label>
<select [disabled]="boTipRec === true" id="ddlReclamo" (change)="selectTipoReclamo()" formControlName="tipoReclamo" [(ngModel)]="TipoReclamoID" class="form-control">
<option value="" disabled>Seleccione Reclamo</option>
<option *ngFor="let item of arrTipRec" [value]="item.tipRec_IDTipoReclamo">
{{ item.tipRec_nombre }}
</option>
</select>
</div>
</div>
</div>
TS:
boTipRec = false;
cargaSelectTipoReclamo() {
try {
this.objIDArServ = {
tipRec_IDArServ: this.frmGenerar.areaServicio.value
};
this.ddlService.selectTipoReclamo(this.objIDArServ).subscribe(data => {
this.arrTipRec = JSON.parse(data);
this.arServ = this.arrArServ.filter(x => x.arServ_IDAreaServicio === +this.frmGenerar.areaServicio.value)[0];
this.selectTipoReclamo();
});
if (this.objReclamo === null) {
this.frmGenerar.tipoReclamo.setValue('');
this.boTipRec = true;
}
} catch (error) {
console.log(error);
}
}
有任何想法吗?
解决方案
只要它实际上进入您的 if 子句,它就应该起作用。
你确定this.objReclamo
真的是这样null
吗?
这是一个带有更改事件的简单示例,显示了它是如何工作的:
https ://stackblitz.com/edit/angular-pucc3q
推荐阅读
- java - android studio 中的 Flight Passanger 详细信息
- c++ - Visual Studio 的 LNK2019 错误 - 未解析的外部符号
- html - Safari 不能正确渲染 px 值?
- javascript - JavaScript / jQuery:将项目推送到数组/对象,每个项目具有相同的键
- python - groupby 值的计数不等于其他 col 值 pandas
- javascript - 当我在 React Native 中下载已上传到 Google Drive 的文件时,我得到的文件大小与原始文件不同
- flutter - Google Play 发布前报告
- bash - 在 bash shell -E 选项解释中,“子shell环境继承的任何陷阱”是什么意思?
- python - 从python中的列表中删除中间成员或成员
- php - 如何在wordpress中更改像seo友好的url