这个问题主要是关于 AngularJs 1.x 的 angular-meteor 包
我正在尝试观看流星收集并在更改时进行一些计算。
angular.module('my-app').controller('MyCtrl', ['$scope', '$meteor', function($scope, $meteor) {
var filter = {myfield: 10};
$meteor.subscribe('mycollection', filter);
$scope.mycollection = $scope.$meteorCollection(Mycollection);
$scope.$watch('mycollection', function () {
console.log($scope.mycollection.length)
});
}]);
但它不起作用。watch 函数只会在$scope.mycollection
为空时调用一次,无论 mycollection 已更改多少次。如何观察变化mycollection
?