angular-meteor $ scope = collection.subscribe无法正确绑定/刷新

时间:2015-07-09 15:55:49

标签: angularjs meteor angularjs-scope angular-meteor

流星,流星&角大师。

我是角度流星的新手,面临以下问题。我使用

执行搜索
$scope.Contacts = $meteor.collection(Contacts,false).subscribe('searchString', $scope.searchString);

$scope.Contacts = $scope.$meteorCollection(Contacts,false).subscribe('searchString', $scope.searchString);

并且$scope.Contacts不会刷新。似乎它拥有旧的收藏品(猜测)。我可以看到mongo服务器返回的数据,它们看起来很好。如果我使用$ meteor.foreach遍历集合,你可以看到数据存在。

但是,一旦将第一个搜索结果分配给$scope.Contacts,它就不会再刷新了。我感觉$scope.Contacts保留了自己的"集合"并且只追加来自$meteor.collection的新行/文档。

非常感谢任何帮助。

全部谢谢,

索蒂里斯

1 个答案:

答案 0 :(得分:1)

有点奇怪。根据我的理解,subscribe链接数据pipline,collections是数据的代表。

$scope.meteorSubscribe('contacts');
$scope.contacts = $scope.$meteorCollection(function (){
  Contacts.find({someField: $scope.searchString})
}

你可能想要这样的东西吗?

相关问题