角函数有错误两个参数:[$解析:语法] [英] Angular function with two parameters having Error: [$parse:syntax]

查看:218
本文介绍了角函数有错误两个参数:[$解析:语法]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

完整的错误是:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆