Skip to content

Commit fa721f2

Browse files
committed
docs: Update tutorial with the new auto subscribe in urigo:ngmeteor
1 parent 940457e commit fa721f2

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

docs/angular-meteor/client/views/steps/tutorial.step_03.html

+6-15
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,15 @@
5252
Notice that this code runs outside of the isClient statement.
5353
That means that this collection and the actions on it will run both on the client (minimongo) and the server (Mongo) and Meteor will take care of syncing them both.
5454

55-
Now that we've created the collection, our client needs to subscribe to it's changes.
56-
We do this with the Meteor.subscribe function:
57-
58-
Add
59-
60-
Meteor.subscribe("parties");
61-
62-
Inside the PartiesListCtrl controller.
63-
64-
65-
So now, we have a parties Meteor collection and a parties AngularJS collection, but they are not binded to each other.
55+
Now that we've created the collection, our client needs to subscribe to it's changes and bind it to our parties AngularJS collection.
6656

6757
To bind them we are going to use angular-meteor built-in [service](https://docs.angularjs.org/guide/services) called $collection.
6858

69-
We are going to replace the declaration of $scope.parties with the following command:
59+
The $collection.bind function will not only bind but also subscribe to the parties Mongo collection.
60+
61+
We are going to replace the declaration of $scope.parties with the following command inside the PartiesListCtrl controller:
7062

71-
$collection(Parties).bind($scope, 'parties', true);
63+
$collection(Parties).bind($scope, 'parties', true, true);
7264

7365
That line declares a new $scope.parties variable so we don't need to do something like $scope.parties = []; and then binds it to the Parties Mongo collection.
7466

@@ -91,8 +83,7 @@
9183
angular.module("socially").controller("PartiesListCtrl", ['$scope', '$collection',
9284
function($scope, $collection){
9385

94-
Meteor.subscribe("parties");
95-
$collection(Parties).bind($scope, 'parties', true);
86+
$collection(Parties).bind($scope, 'parties', true, true);
9687

9788
}]);
9889
}

docs/angular-meteor/client/views/steps/tutorial.step_04.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@
123123
angular.module("socially").controller("PartiesListCtrl", ['$scope', '$collection',
124124
function($scope, $collection){
125125

126-
Meteor.subscribe("parties");
127-
$collection(Parties).bind($scope, 'parties', true);
126+
$collection(Parties).bind($scope, 'parties', true, true);
128127

129128
$scope.remove = function(party){
130129
$scope.parties.splice( $scope.parties.indexOf(party), 1 );

0 commit comments

Comments
 (0)