0
  1. When I click on a single input, all inputs are triggered.
  2. I just want the input I clicked to be triggered

enter image description here

enter image description here

<tr *ngFor="let item of TransferCardWeb">
                            <td>{{item.PartiNo}}</td>
                            <td>{{item.SeriNo}}</td>
                            <td>{{item.StokKodu}}</td>
                            <td>{{item.StokAdi}}</td>
                            <td>
                          <tr *ngIf="!visible"  (click)="itemQuantityOnClick()"> {{item.Quantity}} 

(click)="itemQuantityOnClick() : What should I write inside this method?

                          </tr>

                          <tr *ngIf="visible">
                            <input type="number" [(ngModel)]="item.NewQuantity" min="0" (keydown)="itemQuantityChangeKey($event,item)"
                              style="width:100%; height:100%;">
                          </tr>

Typescript

itemQuantityOnClick()
  {       
    this.visible = true;
          }
ypahalajani
  • 770
  • 1
  • 6
  • 18
  • this should help you https://stackoverflow.com/questions/36006894/angular2-get-clicked-element-id – Tobias S. Aug 15 '21 at 16:38
  • I have only one input.It is filled in javascript according to the incoming values and multiplies @TobiasS. – Metehan Şimşek Aug 15 '21 at 16:48
  • 1
    You should asign an Id to each input. Change the ngFor to ```*ngFor="let item of items; let i = index"``` so you have ```i```` to use as id of the ```input```. Then you can retrieve the id of the clicked input inside ```itemQuantityOnClick()```. – Tobias S. Aug 15 '21 at 16:57
  • Go to your **item** `interface` and add a variable to respond to your condition. In your template, inside the `*ngFor directive` pass the object to the function. – Mohamed Karkotly Aug 15 '21 at 18:44
  • Yess , good plan bro.Thanks man.I will do try @TobiasS. – Metehan Şimşek Aug 15 '21 at 21:49

0 Answers0