Angular 如果值是异步的,如何在函数中使用ngModel旧值?

Angular 如果值是异步的,如何在函数中使用ngModel旧值?,angular,asynchronous,angular-ngmodel,Angular,Asynchronous,Angular Ngmodel,我有一个输入(下拉列表),在获得新输入时,我想检查有关旧输入和新输入的信息。但是,我只有异步格式的数据(旧输入) <p-dropdown [options]="valueOptions" [ngModel]="storeValue$ | async" (ngModelChange)="checkChange($event, ???)" </p-dropwdown> 您可以使用运算符存储初始值。然后可以与当前值进行比

我有一个输入(
下拉列表
),在获得新输入时,我想检查有关旧输入和新输入的信息。但是,我只有异步格式的数据(旧输入)

<p-dropdown [options]="valueOptions" [ngModel]="storeValue$ | async"
 (ngModelChange)="checkChange($event, ???)" </p-dropwdown>
您可以使用运算符存储初始值。然后可以与当前值进行比较

组件。ts

storeValue$.pipe(tap(value=>this.initialValue = value));

checkChange(newValue){
    this.initialValue === newValue;
}

伟大的不客气
<p-dropdown *ngIf="storeValue$ | async as val" [options]="valueOptions" [ngModel]="val"
 (ngModelChange)="checkChange($event, val)" </p-dropwdown>
storeValue$.pipe(tap(value=>this.initialValue = value));

checkChange(newValue){
    this.initialValue === newValue;
}