Sotiris Karanasios Sotiris Karanasios - 1 year ago 40
AngularJS Question

angular-meteor $scope=collection.subscribe does not bind/refresh correctly

meteor, meteor & angular gurus.

I am really new to angular-meteor and facing the following problem. I perform a search using

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


or

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


and the
$scope.Contacts
does not refresh. It seems like its holds the old collection (speculation). I can see the data being returned by the mongo server and they look fine.If I iterate through the collection using $meteor.foreach you can see that the data are there.

But once the first search result is assigned to
$scope.Contacts
it wont refresh any more. I am having the feeling that
$scope.Contacts
keeps its own "collection" and only append new rows/docs coming from
$meteor.collection
.

Any help would be greatly appreciated.

Thanks All,

Sotiris

Answer Source

It's kind of weird. From my understanding, subscribe is linking the data pipline, collections is the representative of the data.

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

You might want something like this?