angular - 更改后如何以角度更新单个变量
问题描述
我有一个步进器,在步骤 n.1 上有以下选择:
<nb-select selected="INFO" (selectedChange)="changeStepperIDDevice($event)" placeholder="Disabled option">
<nb-option value="INFO" disabled>Select Device...</nb-option>
<nb-option *ngFor="let obj of deviceIDList" [value]="obj">{{obj}}</nb-option>
</nb-select>
当我选择我的设备时
changeStepperIDDevice = async (event) => {
this.selectedStepperIDDevice = event;
}
在步骤 n.2 中,我选择了与 obj 相同的选择
<nb-select selected="DEVICE" disabled placeholder="Disabled">
<nb-option value="DEVICE">{{selectedStepperIDDevice}}</nb-option>
</nb-select>
但是 id 不起作用......它是空的......如果我,例如,输入做同样的事情
<input type="text" nbInput placeholder={{selectedStepperIDDevice}} disabled size="40%" />
它工作......它向我展示了选定的设备......但我只是希望它与选择一起工作,这样我就可以一步一步地设置设备
谁能帮我?
太感谢了
解决方案
只需以这种方式修复它:
删除:
<nb-select selected="DEVICE" disabled placeholder="Disabled">
<nb-option value="DEVICE">{{selectedStepperIDDevice}}</nb-option>
</nb-select>
并添加:
<nb-select #myselect [selected]="selectedStepperIDDevice" disabled placeholder="Disabled">
<nb-option *ngFor="let obj of deviceIDList" [value]="obj">{{obj}}</nb-option>
</nb-select>