在Angular / typescript中,是否可以将列表中的对象实例更新为新对象,并在.html的绑定列表中显示更改?
代码:
// this works
this.Items[0] = this.Items[1]
//this does NOT work.
let newItem = new Item();
newItem.Id = x;
this.Items[0] = newItem;
draw(deckId: string, count: number): Observable<Deck> {
return this.http.get<Deck>(url).pipe(catchError(this.handleError));
}
drawThreeCards() {
this.deckService.draw(this.deck.deck_id, 3).subscribe(data => {
this.cards = data;
}
drawOneCards() {
this.deckService.draw(this.deck.deck_id, 1).subscribe(data => {
// Just as test I want to set the first card in the current
// this.cards to the new card drawn
let match = this.cards.find(x => x.Id == this.Items[0].code);
match = this.data;
}