Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Urigo committed May 21, 2015
2 parents 1e86f0a + 4989b1a commit f84017b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 11 additions & 2 deletions .docs/angular-meteor/client/views/api/api.meteorObject.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
Finds the first document that matches the selector, as ordered by sort and skip options.
Wraps [collection.findOne](http://docs.meteor.com/#/full/findone)

Calling $scope.$meteorObject is exactly the same but additionally it will automatically stop the object when the scope is destroyed.
Therefor this is the recommended method.
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.

----

Expand All @@ -25,6 +24,12 @@

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

If you documents are saved with objects IDs (and not strings: <a href="http://docs.meteor.com/#/full/mongo_collection" >see here </a>),
you should use <code> new Mongo.objectID </code> to retieve the object.

$meteor.object (collection, new Meteor.ObjectID (stringId), auto);


### Arguments


Expand Down Expand Up @@ -104,6 +109,7 @@

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


$scope.partyNotAuto = $scope.$meteorObject(Parties, $stateParams.partyId, false);

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

</div>
</template>



11 changes: 8 additions & 3 deletions modules/angular-meteor-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ angularMeteorObject.factory('AngularMeteorObject', ['$q', '$meteorSubscribe', fu

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

var createAngularMeteorObject = function(collection, id, options){
Expand All @@ -108,9 +109,13 @@ angularMeteorObject.factory('$meteorObject', ['$rootScope', '$meteorUtils', 'Ang
function($rootScope, $meteorUtils, AngularMeteorObject) {
return function(collection, id, auto, options) {
// Validate parameters
if (!(collection instanceof Meteor.Collection)) {
throw new TypeError("The first argument of $collection must be a Meteor.Collection object.");
if (!collection) {
throw new TypeError("The first argument of $meteorCollection is undefined.");
}
if (!angular.isFunction(collection.findOne)) {
throw new TypeError("The first argument of $meteorCollection must be a function or a have a findOne function property.");
}

auto = auto !== false; // Making auto default true - http://stackoverflow.com/a/15464208/1426570

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

0 comments on commit f84017b

Please sign in to comment.