Skip to content

Commit f84017b

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 1e86f0a + 4989b1a commit f84017b

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.docs/angular-meteor/client/views/api/api.meteorObject.html

+11-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
Finds the first document that matches the selector, as ordered by sort and skip options.
1515
Wraps [collection.findOne](http://docs.meteor.com/#/full/findone)
1616

17-
Calling $scope.$meteorObject is exactly the same but additionally it will automatically stop the object when the scope is destroyed.
18-
Therefor this is the recommended method.
17+
Calling $scope.$meteorObject is exactly the same but additionally it will automatically stop the object when the scope is destroyed; therefore this is the recommended method.
1918

2019
----
2120

@@ -25,6 +24,12 @@
2524

2625
$scope.$meteorObject(collection, selector, auto)
2726

27+
If you documents are saved with objects IDs (and not strings: <a href="http://docs.meteor.com/#/full/mongo_collection" >see here </a>),
28+
you should use <code> new Mongo.objectID </code> to retieve the object.
29+
30+
$meteor.object (collection, new Meteor.ObjectID (stringId), auto);
31+
32+
2833
### Arguments
2934

3035

@@ -104,6 +109,7 @@
104109

105110
$scope.party = $meteor.object(Parties, $stateParams.partyId);
106111

112+
107113
$scope.partyNotAuto = $scope.$meteorObject(Parties, $stateParams.partyId, false);
108114

109115
$scope.save = function() {
@@ -129,3 +135,6 @@
129135

130136
</div>
131137
</template>
138+
139+
140+

modules/angular-meteor-object.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ angularMeteorObject.factory('AngularMeteorObject', ['$q', '$meteorSubscribe', fu
8282

8383
// A list of internals properties to not watch for, nor pass to the Document on update and etc.
8484
AngularMeteorObject.$$internalProps = [
85-
'save', 'reset', '$$collection', '$$options', '$$id', '$$hashkey', '$$internalProps', 'subscribe', 'stop', 'autorunComputation', 'unregisterAutoBind', 'unregisterAutoDestroy', 'getRawObject'
85+
'save', 'reset', '$$collection', '$$options', '$$id', '$$hashkey', '$$internalProps', 'subscribe', 'stop', 'autorunComputation', 'unregisterAutoBind', 'unregisterAutoDestroy', 'getRawObject',
86+
'collection', '_eventEmitter'
8687
];
8788

8889
var createAngularMeteorObject = function(collection, id, options){
@@ -108,9 +109,13 @@ angularMeteorObject.factory('$meteorObject', ['$rootScope', '$meteorUtils', 'Ang
108109
function($rootScope, $meteorUtils, AngularMeteorObject) {
109110
return function(collection, id, auto, options) {
110111
// Validate parameters
111-
if (!(collection instanceof Meteor.Collection)) {
112-
throw new TypeError("The first argument of $collection must be a Meteor.Collection object.");
112+
if (!collection) {
113+
throw new TypeError("The first argument of $meteorCollection is undefined.");
113114
}
115+
if (!angular.isFunction(collection.findOne)) {
116+
throw new TypeError("The first argument of $meteorCollection must be a function or a have a findOne function property.");
117+
}
118+
114119
auto = auto !== false; // Making auto default true - http://stackoverflow.com/a/15464208/1426570
115120

116121
var data = new AngularMeteorObject(collection, id, options);

0 commit comments

Comments
 (0)