Reputation: 443
How to passing value from component to js file ? Thank you very much.
app.component.html
<table>
<tr>
<td>Time</td>
<td>Title</td>
</tr>
<tr *ngFor="let data of dataList">
<td>
<a href="#" onClick="openWin()">{{data.createDatetime}}</a>
</td>
<td>
<a href="#" onClick="openWin(data.title)">{{data.title}}</a>
</td>
</tr>
</table>
script.js (in assets folder)
function openWin(title) {
// open popup windows
// show title
}
Upvotes: 2
Views: 93
Reputation: 222722
You need to use (click) instead of onclick with angular
<a href="#" (click)="openWin(data)">
And inside ts,
openWin(data:any){
console.log(data.title);
}
Upvotes: 1