簡體   English   中英

Angularjs ng-單擊重復表行不起作用

[英]Angularjs ng-click on repeat table row not working

在AngularJS中,單擊以下HTML對我不起作用

<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”功能就是

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

你做錯了。 您不應該在Angular指令( ng-click )中使用花括號,因為此語法針對模板。

一個正確的方法:

<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;
  //...
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM