我是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>