You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-6
Original file line number
Diff line number
Diff line change
@@ -44,15 +44,16 @@ ngMeteor provides an AngularJS service called $collection, which is a wrapper fo
44
44
| selector |[Mongo Selector (Object or String)](http://docs.meteor.com/#selectors)| Same as [Meteor Collection Find](http://docs.meteor.com/#find)| No |
45
45
| options | Object | Same as [Meteor Collection Find](http://docs.meteor.com/#find)| No |
46
46
47
-
The $collection service only has one method, and that is <code>bind</code>, which is used to bind the collection to an Angular model so that you can use it in your scope:
47
+
<code>bind</code>, which is used to bind the collection to an Angular model so that you can use it in your scope:
| scope | Scope | The scope the collection will be bound to. | Yes ||
54
-
| model | String | The model the collection will be bound to. | Yes ||
55
-
| auto | Boolean | By default, changes in the model will not automatically update the collection. However if set to true, changes in the client will be automatically propagated back to the collection. A deep watch is created when this is set to true, which sill degrade performance. | No | false |
| scope | Scope | The scope the collection will be bound to. | Yes ||
54
+
| model | String | The model the collection will be bound to. | Yes ||
55
+
| auto | Boolean | By default, changes in the model will not automatically update the collection. However if set to true, changes in the client will be automatically propagated back to the collection. A deep watch is created when this is set to true, which sill degrade performance. | No | false |
56
+
| publisher | Boolean/String | By default, bind method will not automatically subscribe to the collection. However if set to true, bind will call Meteor.subscribe on the current collection. you can also set publisher to a string and then bind will call Meteor publish with that string. | No | false |
56
57
57
58
Once a collection has been bound using the <code>bind</code> method, the model will have access to the following methods for upserting/removing objects in the collection. If the <code>auto</code> argument as been set to true, then the user will not need to call these methods because these methods will be called automatically whenever the model changes.
58
59
@@ -145,6 +146,19 @@ For example:
145
146
| auto | Boolean | By default, changes in the model will not automatically update the collection. However if set to true, changes in the client will be automatically propagated back to the collection. A deep watch is created when this is set to true, which sill degrade performance. | No | false |
146
147
147
148
149
+
### Subscribe
150
+
151
+
ngMeteor provides an AngularJS service called $subscribe, which is a wrapper for [Meteor.subscribe](http://docs.meteor.com/#meteor_subscribe) to subscribe the client to a Meteor.publish Method within AngularJS with promises.
152
+
153
+
$subscribe.subscribe(name, subscribeArguments)
154
+
155
+
Returns a promise when subscription is ready.
156
+
157
+
$subscribe.subscribe('todos').then(function(){
158
+
console.log($scope.todos);
159
+
});
160
+
161
+
148
162
### Adding controllers, directives, filters and services
149
163
It is best practice to not use globally defined controllers like they do in the AngularJS demos. Always use the exported package scope ngMeteor as your angular module to register your controller with $controllerProvider. Furthermore, to prevent errors when minifying and obfuscating the controllers, directives, filters or services, you need to use [Dependency Injection](http://docs.angularjs.org/guide/di). For example:
0 commit comments