This API is deprecated since version 1.3.0 and no longer available since version 1.3.1

$meteorUtils

A service which contains helpful utilities for angular-meteor applications


$meteor.autorun / $scope.$meteorAutorun has been deprecated in favor of the autorun API.

In the previous version of Angular-Meteor we wrapped Meteor’s autorun method, but now we put that wrapper on your context (controllerAs or $scope).

Angular-Meteor will also automatically stop the autorun when the $scope is destroyed.

Here is an example for how to migrate:

Old code:

angular.module(`myApp`, []).controller(`MyCtrl`, function($scope) {
  $scope.meteorAutorun(function() {

  });
});

New Code:

Example using $scope:

angular.module(`myApp`, []).controller(`MyCtrl`, function($scope) {
  $scope.autorun(function() {

  });
});

Example using controllerAs and components:

angular.module(`myApp`, []).directive(`myComponent`, function() {
  return {
    restrict: `E`,
    controllerAs: `myCtrl`,
    controller: function($scope, $reactive) {
      $reactive(this).attach($scope);
      this.autorun(function() {

      });
    }
  };
});

Example using angular2now and ReactiveComponent:

let {Component} = angular2now;
angular.module(`myApp`);

@Component({selector: `my-component`})
class myComponent extends ReactiveComponent {
  constructor() {
    super(arguments);
    this.autorun(function() {

    });
  }
}

Usage

$meteor.autorun( :scope, :function );  /  $scope.$meteorAutorun( :function );

$meteor.getCollectionByName( :collectionName );

Methods

autorun( :scope, :function )

$scope.$meteorAutorun( :function )

Wrapper function to Meteor's Tracker.autorun.

Keeps the changes in Angular's scope context and closes the autorun when scope automatically destroys.

The two types of syntax works the same way.


Parameters

Param Type Details Required
scope scope

The AngularJS scope you use the autorun on.

Yes
fn function

The function that will re-run every time a reactive variable changes inside it.

Yes

Example

        $meteor.autorun($scope, function() {
      if ($scope.getReactively('currentUser')) {
          $scope.userForScore = $scope.$meteorObject(Userinfo, {user_id: $scope.getReactively('currentUser')._id});//$rootScope.currentUser._id
      }
  });

Method

getCollectionByName( :collectionName )

Parameters

Param Type Details Required
collectionName string

The name of the collection you want to get back

Yes