Home Ask Login Register

Developers Planet

Your answer is one click away!

Hongbo Miao February 2016

How to retrieve data from a table cell in angular 2

I am using Angular 2. I try to retrieve data from a table cell. Is there an Angular 2 way to do this?

I tried to do like this, but I got undefined value.

        <td (click)="getValue($event)">John</td>

getValue(event:any) {
    let value = event.target.value;
    console.log("value", value);


Günter Zöchbauer February 2016

use instead

let value = event.target.text;


let value = event.target.innerHTML;  

The <td> doesn't have a value property.

Post Status

Asked in February 2016
Viewed 3,799 times
Voted 7
Answered 1 times


Leave an answer

Quote of the day: live life