我是MEAN堆栈应用程序的新手,所以我要求帮助 每次AngularJS尝试解析以下代码
<button type="button" class="btn btn-link pull-right" ng-click="delete({{ post._id }});"><span class="glyphicon glyphicon-trash"></span></button>
在控制台中显示以下错误:
Error: [$parse:syntax] http://errors.angularjs.org/1.4.3/$parse/syntax?p0=%7B&p1=invalid%20key&p2=9&p3=delete(%7B%7B%20post._id%20%7D%7D)%3B&p4=%7B%20post._id%20%7D%7D)%3B
at Error (native) https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.js:12330
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:6:416
at Object.q.throwError (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:209:32)
at Object.q.object (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:208:327)
at Object.q.primary (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:205:335)
at Object.q.unary (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:205:174)
at Object.q.multiplicative (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:204:434)
at Object.q.additive (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:204:261)
at Object.q.relational (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:204:96)
at Object.q.equality (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:203:425) <button type="button" class="btn btn-link pull-right" ng-click="delete({{ post._id }});">
但是当我检查删除按钮时,我可以找到:
<button type="button" class="btn btn-link pull-right" ng-click="delete(55ba1c2d6411b92c1715490c);"><span class="glyphicon glyphicon-trash"></span></button>
有人可以帮我解决这个问题吗?
答案 0 :(得分:1)
从ng-click属性中删除{{ }}
,在这种情况下不需要:
ng-click="delete(post._id);"
为什么?
https://docs.angularjs.org/api/ng/directive/ngClick
ng-click指令接受一个在点击时评估的表达式。