ниже упоминается выход
file.
Код: Выделить всё
export class ProductsComponent implements OnInit {
@ViewChildren('quantityreference') dynamicElements!: QueryList;
productlists = JSON.parse(`[
{
"productId": "T00110",
"productName": "first",
"productPrice": "0",
"gst":"20"
},
{
"productId": "T000",
"productName": "Punnakuuu",
"productPrice": "40",
"gst":"20"
},
{
"productId": "T1111",
"productName": "Thenkaai Punnaku",
"productPrice": "40",
"gst":"18"
},
{
"productId": "MT1",
"productName": "Mattu Theevanam",
"productPrice": "55",
"gst":"18"
},
{
"productId": "CP1",
"productName": "m Punnaku",
"productPrice": "55",
"gst":"12"
},
{
"productId": "CP2",
"productName": "ell Punnaku",
"productPrice": "22",
"gst":"12"
}]`
);
constructor() { }
purchasedProudct = new Purchasedproduct("", "", 0, 0, "");
selectedquantity: number = 0;
@ViewChildren('quantityreference', { read: ElementRef }) products!: QueryList;
ngOnInit(): void {
}
increment(indexvalue: number) {
const item = this.productlists[indexvalue];
this.selectedquantity++;
}
decrement(indexvalue: number) {
const item = this.productlists[indexvalue];
if (this.selectedquantity > 0) {
this.selectedquantity--;
}
}
}
< /code>
my .html file < /h2>
0">
[h4]{{product.productName}}[/h4]
Rs. {{product.productPrice}}
remove
add
Подробнее здесь: https://stackoverflow.com/questions/797 ... d-or-templ