Reputation: 81
How can I get a row value, when click cell in ng-grid
?
example:
Name Number Class
X 123 A
Y 234 B
Z 345 C
A 456 D
When click on 123 cell or A cell or X cell, how can i get value X.
Please any help me. thanks in Advance
Upvotes: 1
Views: 2446
Reputation: 136184
You should write ng-click
of cellTemplate ng-click="clicked(row)"
Controller
$scope.clicked = function(row){
alert(row.getProperty("Name"));
};
Upvotes: 0
Reputation: 62881
One option - add an ng-click
function on each row that returns the value in the first column.
HTML
<tr ng-repeat="item in items" ng-click="getVal(item)">
<td>{{item.name}}</td>
<td>{{item.number}}</td>
<td>{{item.class}}</td>
</tr>
Controller
$scope.getVal = function(item) {
alert(item.name);
}
Here's a working demo.
Upvotes: 0