@Vartex05 wrote:
Hi, in my ionic 5 app, i encountered strange problem with change detection. In my Cart page, i display list of products, and user can send order with fab button. Everything works, but when i hit the button, i want to reset all items, that are displayed. I do this in processTransacton method.
Problem is, that it doesnt trigger change detection, so old items doesnt disappear until i hit another button on the page. Any ideas what can cause this? My code looks like this:<ion-content class="ion-padding"> <ion-button expand="block" (click)="openProductList()">Přidat položku</ion-button> <div *ngFor="let product of selectedProducts"> <app-cart-item [cartItem]="product" (remove)="removeProduct($event)"> </app-cart-item> </div> <ion-fab vertical="bottom" horizontal="end" slot="fixed"> <ion-fab-button color="success" (click)="processTransaction()"> <ion-icon name="checkmark-outline"></ion-icon> </ion-fab-button> </ion-fab> </ion-content>
processTransaction(){ this.productService.sendOrderCash([...this.selectedProducts]).subscribe(result=>{ this.lastSelection=[...this.selectedProducts]; this.selectedProducts=[]; console.log(this.selectedProducts); }); }
Posts: 1
Participants: 1