错误:关键$$ hashKey不能以“$”开头(AngularJS) [英] Error: key $$hashKey must not start with '$' (AngularJS)
问题描述
尝试添加一些我的收藏时,我得到了以下错误:
Attempting to add something to my collection when I got the following error:
Exception while invoking method 'submit' Error: key $$hashKey must not start with '$'
每个餐对象:
$scope.meal = {
items:[],
createdBy:null
};
下面是我提出我的控制器内的功能:
Here is my submit function inside my controller :
$scope.submit = function() {
var currentUserId = Meteor.userId();
if(currentUserId!=null) {
if($scope.checkValidity()==false) {
alert("Need to fill out valid calories and/or items!");
}
else {
$scope.meal.createdBy = currentUserId;
Meteor.call("submit", $scope.meal);
alert("has just been submitted");
}
}
else {
alert("You must sign in first!");
}
}
我已经盘问我提交功能,无数次,但我似乎无法找到一个错误。我看对谷歌以及的这个错误,它似乎是它的一点点在我的头上,特别是因为我还是一个初学者角。在此期间,我会试图找到更多的信息。
I've cross examined my submit function numerous times but I can't seem to find an error. I've looked on google as well of this error and it seems like its a little over my head especially because I'm still a Angular beginner. In the meantime, I'll attempt to find more information.
发现了一些信息: https://github.com/Urigo/angular-meteor/问题/ 299
好像他们从固定的意见呢?然而,同样的问题已经up..Check出来。
Seems like they fixed it from the comments? Yet the same problem has come up..Check it out.
推荐答案
为对象添加到吃饭的项目,请尝试使用:
to add a object to the items of the meal, try using:
$scope.meal.items.push(angular.copy($scope.newItem));
当你骂
Meteor.call("submit", angular.copy($scope.meal));
这是因为角度使用引用跟踪对象
this is because angular uses a reference to track the object
这篇关于错误:关键$$ hashKey不能以“$”开头(AngularJS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!