Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
153
rated 0 times [  157] [ 4]  / answers: 1 / hits: 78502  / 11 Years ago, fri, march 8, 2013, 12:00:00

ng-click on the following HTML is not working for me in AngularJS



<tr ng-repeat=ai in alert_instances ng-click=go('/alert_instance/{{ai.alert_instancne_id}}')>
<td>{{ai.name}}</td>
<td>{{ai.desc}}</td>
</tr>


The go function in my controller at the moment just has



$scope.go = function (hash) {
console.log(hi)
};

More From » angularjs

 Answers
4

You are doing it wrong. You shouldn't be using curly braces in Angular directives (ng-click), as this syntax is aimed for templates.



A proper way:



<tr ng-repeat=ai in alert_instances ng-click=go(ai)>
<td>{{ai.name}}</td>
<td>{{ai.desc}}</td>
</tr>

$scope.go = function(ai) {
var hash = '/alert_instance/' + ai.alert_instancne_id;
//...
};

[#79741] Thursday, March 7, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jarod

Total Points: 62
Total Questions: 111
Total Answers: 83

Location: Saint Vincent and the Grenadines
Member since Sat, Sep 11, 2021
3 Years ago
jarod questions
;