本文介绍了Angularjs ng-单击重复表行不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
点击以下HTML在AngularJS中对我不起作用
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>
目前我的控制器中的go功能只有
The "go" function in my controller at the moment just has
$scope.go = function (hash) {
console.log("hi")
};
推荐答案
你做错了。你不应该在Angular指令中使用花括号( ng-click
),因为这种语法是针对模板的。
You are doing it wrong. You shouldn't be using curly braces in Angular directives (ng-click
), as this syntax is aimed for templates.
正确的方法:
<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;
//...
};
这篇关于Angularjs ng-单击重复表行不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!