eri*_*bae 37 javascript angularjs
在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>
Run Code Online (Sandbox Code Playgroud)
目前我的控制器中的"go"功能就是
$scope.go = function (hash) {
console.log("hi")
};
Run Code Online (Sandbox Code Playgroud)
Łuk*_*man 89
你做错了.您不应该在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;
//...
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
74565 次 |
| 最近记录: |