我是 angularjs 新手,我正在创建一个函数。该函数有一个类似 {{sched.an_id}}
的参数。但这不起作用。这是我的代码:
$scope.sample = function(val){
alert(val);
};
HTML
<table>
<tr ng-repeat='sched in schedule'>
<td>
<a ng-click="sample({{sched.an_id}})"></a>
</td>
</tr>
</table>
在上面的 html 中,它不会提醒 sample()
的值。我尝试检查该元素,它给出了准确的值sample(23)
。我尝试删除 {{sched.an_id}}
并替换 sample(123)
它有效。我该怎么办?
最佳答案
这是因为您在 ng-click
中使用了 {{}}
试试这个
<a ng-click="sample(sched.an_id)"></a>
关于javascript - 当参数为 'view' 时,Angularjs 的函数不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42264125/