Following changes should work.
HTML:
<div class="col-12 " *ngFor="let addedItem of items; let i = index ">
<ul>
<li> {{addedItem.name }} <button class="btn" (click)="removeItem(i)"> delete </button> </li>
</ul>
</div>
cartComponent.ts
removeItem(index: number) {
this.cartService.removeItem(index);
}
cartService.ts
removeItem(index: number){
this.items.splice(index, 1);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…