angularjs - 错误: key $$hashKey must not start with '$' (AngularJS)

标签 angularjs meteor

尝试向我的收藏中添加内容时出现以下错误:

Exception while invoking method 'submit' Error: key $$hashKey must not start with '$'

每餐对象:

$scope.meal = {
  items:[],
  createdBy:null
};

这是我的 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!");
  }
}

我已经多次检查了我的提交函数,但我似乎找不到错误。我也在谷歌上查看过这个错误,它似乎有点超出我的理解范围,特别是因为我仍然是一个 Angular 初学者。与此同时,我将尝试寻找更多信息。

找到一些信息:https://github.com/Urigo/angular-meteor/issues/299

好像他们从评论中修复了它?然而同样的问题又出现了..检查一下。

最佳答案

要将对象添加到餐食中,请尝试使用:

  $scope.meal.items.push(angular.copy($scope.newItem));

当你打电话时

 Meteor.call("submit", angular.copy($scope.meal));

这是因为 Angular 使用引用来跟踪对象

关于angularjs - 错误: key $$hashKey must not start with '$' (AngularJS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32173465/

相关文章:

javascript - jQuery deferred.always() 回调的 Angular 等价物

jquery - 使用 AngularJS 和 jQuery Mobile 进行路由

javascript - AngularJs:ng-View 不更新

javascript - 在 Angular 中使用 $http 应用curl POST 请求

Javascript 音频文件 "previous/next"文件/歌曲跳过功能?

jquery-mobile - 当meteor js元素/字段更新时保留jquery移动样式

javascript - 如何检索Cloudinary photoid?

javascript - 如何在 Meteor javascript 文件中使用 MongoDB mapReduce 函数?

javascript - meteor 铁路由器 : custom id route

javascript - 在 Angular Meteor 中使用 Blaze 模板