2 回答

TA貢獻1865條經(jīng)驗 獲得超7個贊
所以我從您的代碼中知道的是,您總共有三個列表。
您用于迭代(ngFor)的一個,其他兩個已批準,如果我錯了,請拒絕糾正我。
一種方法是將一個對象與您的產(chǎn)品一起使用,并將另一個鍵用作狀態(tài)并根據(jù)按鈕的單擊更改值。
或者
將這些行添加到您的代碼中:
if(status === 'approved'){
//this line will remove the product from declined list
this.declined = this.declined.filter(function(value, index, arr){
return value!== product;
});
this.approved.push(product)
}else {
//this line will remove the product from approved list
this.approved= this.approved.filter(function(value, index, arr){
return value!== product;
});
this.declined.push(product)
}
}
注意:請確保您從正確的列表中顯示結(jié)果。
添加回答
舉報