首页 > 解决方案 > 触发事件时立即更新选择下拉列表

问题描述

我有带有下拉列表的选择框。此数据来自响应所以我想在更改数据时更新数据。

<mat-select placeholder="Kategorie auswählen" [(ngModel)]="categoryid" (selectionChange)="categorychanged(categoryid)">
     <mat-option *ngFor="let category of mainshoppinglistitems" [value]="category._id">
          {{category.dishType}}
     </mat-option>
 </mat-select>

因此,如果我触发事件并尝试从响应中更改数据。当我单击选择框时,它没有更新。

getUpdateData() {
     this.cartservice.getShoppingListOnly().then(response => {
      this.mainshoppinglistitems = response['data'];
    });
}

更改时如何更新DOMmainshoppinglistitems

标签: angular

解决方案


推荐阅读