Answer the question
In order to leave comments, you need to log in
How to make the method work only on the required element from *ngFor?
The plugin has a list of products that is rendered via *ngFor :
<ul class="cart">
<li *ngFor="let item of cartService.cart$ | async">//BehaviorSubject
<h3 class="title">{{item.title}}</h3>
<span class="descr">{{item.description}}</span>
<button (click)="decrQnt()">-</button>
<form action="#">
<input type="text" maxlength="3" id="qnt" readonly="readonly" value="{{qnt}}">
</form>
<button (click)="incrQnt()">+</button>
</li>
</ul>
public qnt: number = 1;
incrQnt(){
this.qnt < 100 ? ++this.qnt : 0;
}
Answer the question
In order to leave comments, you need to log in
In short, in order not to invent tops, I added the qnt property to the json object and everything became OK.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question