0

Hello friends I have a problem with a table that paint a td dinamically within a tr using ngFor structural directive.

In the below case the td generated with de ngFor no throwing dblclick howerver click its works!

<table>
        <thead>
            <tr>
                <td *ngIf="deleteActive" class="delete-input">#</td>
                <th *ngFor="let f of tableFields">{{f}}</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let r of tableData; index as i" (click)="rowClick(i,r)" (dblclick)="foo()" [ngClass]="{'selected': (i == selectedElementIndex)}">
                <td *ngIf="deleteActive" class="delete-input"><input type="checkbox" (click)="selectedToDelete(i,r)"></td>
                <td>{{r.name}}</td>
                <td *ngFor="let authority of getAuthorities(r.authorities)">
                    ae
                </td>
            </tr>
        </tbody>
    </table>

When tds are static this problem does not occur, only appear when the td are generated dinamically using ngFor directive.

Thanks and I hope help me!

  • hi and welcome to Stackoverflow. On your example we can't see any dblclick event binding. Is also better if you provide us what you have on your `component.ts` – Yanis-git May 07 '18 at 08:37
  • Thanks!!. In the example, the dblclick event its in tr tag, where you see also click binding event! – Antonio de la mata May 07 '18 at 09:37
  • 1
    Possible duplicate of [Angular 2 (click) and (dblclick) on the same element not working good?](https://stackoverflow.com/questions/36113861/angular-2-click-and-dblclick-on-the-same-element-not-working-good) – user184994 May 07 '18 at 11:14
  • No. When the td tag is not dynamically created the click and double click event work fine :D – Antonio de la mata May 07 '18 at 11:22

0 Answers0