首页 > 解决方案 > 设置选项后启用选择控制以选择上一个

问题描述

我有一个带有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);
}
}

有任何想法吗?

标签: angulardrop-down-menucontrols

解决方案


只要它实际上进入您的 if 子句,它就应该起作用。
你确定this.objReclamo真的是这样null吗?

这是一个带有更改事件的简单示例,显示了它是如何工作的:
https ://stackblitz.com/edit/angular-pucc3q


推荐阅读