Reputation: 6254
I have this piece of code:
<tr ng-repeat="convention in conventions">
<td>{{ convention.Id }}</td>
<td>{{ convention.Title }}</td>
<td><a href="javascript:void(0)" ng-click="alert(convention.Id)">Edit</a></td>
</tr>
I wanna call a function like alert
and pass Id
as parameter.but It does not render properly:
any suggestion?
Upvotes: 1
Views: 44
Reputation: 41065
Add alert
to your scope, like so in your controller
$scope.alert = function(i) {
alert(i)
};
Upvotes: 2
Reputation: 11317
Wrap the alert()
in a function in your controller and add it to the scope like this:
$scope.handleClick = function(id) {
alert(id);
}
Then call this function from the template:
ng-click="handleClick(contention.Id)"
Expressions embedded in your templates do only see the functions in the respective scope.
Upvotes: 3