角函数有错误两个参数:[$解析:语法] [英] Angular function with two parameters having Error: [$parse:syntax]
问题描述
完整的错误是:
Error: [$parse:syntax] Syntax Error: Token ',' not a primary expression
导致错误的一块code是:
The piece of code causing the error is:
<div ng-repeat="item in items">
<input type="submit" ng-click="delete({{item.itemId}},$index)" value="delete">
</div>
该功能的实际工作为previous项目,但休息时,我尝试一个新的项目我的项目数组。孩子问题似乎是逗号,但我不知道该怎么办。
The function actually works for previous items but breaks when I try a new item to my item array. The problem child appears to be the comma, but I do not know what to do.
推荐答案
您不需要包装 item.itemId
在 {{} }
。只要做到:
You don't need to wrap item.itemId
in {{}}
. Just do:
NG-点击=删除(item.itemId,$指数)
您只需要采用了棱角分明的模板系统时,括号包裹 - 括号告诉角度,以取代的价值。在这种情况下,NG-点击的价值是评估一个前pression(控制器范围内),当点击事件发生。
You only need to wrap in braces when using Angular's templating system - the braces tell Angular to replace the value. In this case, the value of ng-click is an expression that is evaluated (within the scope of your controller) when a click event occurs.
演示<大骨节病> 小提琴 骨节病>
这篇关于角函数有错误两个参数:[$解析:语法]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!