【问题标题】:angular-meteor $scope=collection.subscribe does not bind/refresh correctlyangular-meteor $scope=collection.subscribe 没有正确绑定/刷新
【发布时间】:2016-07-29 19:29:53
【问题描述】:

流星、流星和角度大师。

我对 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 的新行/文档。

任何帮助将不胜感激。

谢谢大家,

Sotiris

【问题讨论】:

    标签: angularjs meteor angularjs-scope angular-meteor


    【解决方案1】:

    这有点奇怪。据我了解,subscribe是链接数据管道,collections是数据的代表。

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

    你可能想要这样的东西?

    【讨论】:

      猜你喜欢
      • 2021-07-25
      • 1970-01-01
      • 2011-10-22
      • 2018-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-15
      • 1970-01-01
      相关资源
      最近更新 更多