0
我有一个meanjs应用。在我的html,我有以下角节点字符串参数转义错误
<button class="btn btn-primary" data-ng-click="addMember({{user._id}});" >
<i class="glyphicon glyphicon-plus"></i>
</button>
的HTML渲染就好了(见下文)
<button class="btn btn-primary" data-ng-click="addMember(55a897dfad783baa677e1326);" >
<i class="glyphicon glyphicon-plus"></i>
</button>
但它确实收到以下错误控制台
Error: [$parse:syntax] Syntax Error: Token 'user._id' is unexpected, expecting [:] at column 13 of the expression [addMember({{user._id}});] starting at [user._id}});].
http://errors.angularjs.org/1.2.28/$parse/syntax?p0=user._id&p1=is%20unexpected%2C%20expecting%20%5B%3A%5D&p2=13&p3=addMember(%7B%7Buser._id%7D%7D)%3B&p4=user._id%7D%7D)%3B
如果我围绕该方法添加单引号
<button class="btn btn-primary" data-ng-click="addMember('{{user._id}}');" >
<i class="glyphicon glyphicon-plus"></i>
</button>
一切都在HTML控制台呈现精细,没有错误,但一旦方法被调用(控制器)
$scope.addMember = function(userid) {
console.log(userid);
};
它输出什么我做错了字符串字面{{user._id}}
代替55a897dfad783baa677e1326
?
使用'NG-click'经过user.id没有'{{}}'。 'NG点击= “使用addMember(user._id);”' –
嘎!谢谢。就是这样。傻我。如果您想您的评论移动到答案,我可以给你它的信用 –
我把它回答。 Thx Ervin。 –