实际上,在选择另一个选择时,它不是按一下按钮,它通过内部进程返回一个数组,我想在其选项中的新选择中显示的数组。
<mat-form-field>
<mat-label>Rutas disponibles</mat-label>
<mat-select id="select1">
<mat-option *ngFor="let mv of moveByDoc" [value]="mv.id">
{{mv.originpath}}
</mat-option>
</mat-select>
</mat-form-field>
加载页面时,此选择显示为空,因为"moveByDoc"仍然为空,然后当单击另一个选择时,它将被填充,当它被填充时,我希望它自动加载这个选项,或者只刷新这个选择。
ts代码,附加不起作用,不添加任何内容:
loadPath(idDoc){
this.authService.getmoveByDoc(idDoc)
.subscribe((res : getmovemodel[])=>{
this.moveByDoc = res;
});
}
它已经工作了,我编辑正确
试试这个:
<mat-form-field *ngIf="moveByDoc">
<mat-label>Rutas disponibles</mat-label>
<mat-select id="select1">
<mat-option *ngFor="let mv of moveByDoc" [value]="mv.id">
{{mv.originpath}}
</mat-option>
</mat-select>
</mat-form-field>
并从 loadPath 中删除不必要的代码:
loadPath(idDoc){
this.authService.getmoveByDoc(idDoc)
.subscribe((res : getmovemodel[])=>{
this.moveByDoc = res;
});
}