2017-10-12 21 views
0

我想在每個行的ng表中爲點擊事件「onListFavorisAdded()」創建一個動態按鈕「Favoris」。該表在組件中創建並配置。所以我也在component.ts中創建了這個按鈕,之後我把它放在html中。該按鈕顯示在我的網頁,但是當我點擊它時不工作...組件中創建的角度爲2/4的事件點擊按鈕

HTML:

<ng-table [config]="config" 
       (tableChanged)="refreshTable(config)" 
       (expanderClicked)="expanderClicked($event)" 
       [rows]="rows" [columns]="columns" 
       [expandable]="true" 
       [expandedComponent]="rowComponent" 
       [rowInputs]="rowInputs"> 
    </ng-table> 

,可給我的組件行的功能:我爲做一個對於那些在創建表

for (let collab of collaborators) { 
     // Add a column name 
     collab.nomPrenom = this.getData(collab, "data.personne.nom", "").toUpperCase() + " " + this.getData(collab, "data.personne.prenom", ""); 

     // Add a column preview 
     collab.preview = '<a class="btn-default" href="#/profile/' + this.getData(collab, "tgi") + '" aria-label="Profile"> <i class="fa fa-eye" aria-hidden="true"></i></a>'; 

     // !!!!! Add a column Favoris !!!!!!!! 
     collab.favoris = '<button data-ng-click="onListFavorisAdded()"><i class="fa fa-star" aria-hidden="true"></i></button>'; 

感謝您的幫助每一行

+0

你使用任何庫 – Aravind

回答

0

你可以做的是使一個表的ngFor它:

<table> 
    <tr> 
     <td *ngFor="let dataRow of Data; let i = index" (click)="onListFavorisAdded()">{{dataRow.name}}</td> 

您在數據中添加的每個項目數組將創建一個新行。

+0

我可以直接在ng表中做到這一點嗎? –

+0

@ L.M我不知道ngTable的功能。你必須自己解決這個問題。 – Swoox

+0

ng-table使用組件中定義的配置和元素創建表 –