Skip to content

Commit

Permalink
docs: Add API reference to $meteorObject
Browse files Browse the repository at this point in the history
  • Loading branch information
Urigo committed Jan 8, 2015
1 parent 63cf1c2 commit 57218b8
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .docs/angular-meteor/client/scripts/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ angular.module("meteor-angular-docs").config(['$urlRouterProvider', '$stateProvi
url: '/meteorCollection',
template: UiRouter.template('api.meteorCollection.html')
})
.state('api.meteorObject', {
url: '/meteorObject',
template: UiRouter.template('api.meteorObject.html')
})
.state('api.collection-bind', {
url: '/collection-bind',
template: UiRouter.template('api.collection-bind.html')
Expand Down
1 change: 1 addition & 0 deletions .docs/angular-meteor/client/views/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ <h2><a href="/api">API</a></h2>
<li><a href="/api/methods">$meteorMethods.call</a></li>
<li><a href="/api/session">$meteorSession.bind</a></li>
<li><a href="/api/user">User</a></li>
<li><a href="/api/meteorObject">$meteorObject</a></li>
<li><a href="/api/getReactivly">$scope.getReactivly</a></li>
<li><a href="/api/meteor-include">meteor-include directive</a></li>
<li><a href="/api/utils">$meteorUtils</a></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<tr>
<td>autoClientSave</td>
<td><a href="" class="label type-hint type-hint-boolean">Boolean</a></td>
<td><p>By default, changes in the Angular collection will not automatically update the Meteor collection.
However if set to true, changes in the client will be automatically propagated back to the collection.</p></td>
<td><p>By default, changes in the Angular collection will automatically update the Meteor collection.
However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.</p></td>
<td><a href="" class="label type-hint type-hint-object">No</a></td>
<td><a href="" class="label type-hint type-hint-boolean">True</a></td>
</tr>
Expand Down
111 changes: 111 additions & 0 deletions .docs/angular-meteor/client/views/api/api.meteorObject.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<template name="api.meteorObject.html">
<div>
<a href="https://github.com/Urigo/angular-meteor/edit/master/.docs/angular-meteor/client/views/api/api.meteorObject.html"
class="btn btn-default btn-lg improve-button">
<i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this doc
</a>

<do-nothing>
{{#markdown}}

# $meteorObject

A service that wraps a Meteor object to enable reactivity within AngularJS.

----

## Usage

$meteorObject(collection, id, auto)

### Arguments



<table class="variables-matrix input-arguments">
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Details</th>
<th>Required</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>collection</td>
<td>
<a href="http://docs.meteor.com/#/full/collections" class="label type-hint type-hint-string">Meteor Collection Object</a>
</td>
<td><p>A Meteor Collection to bind to.</p></td>
<td><a href="" class="label type-hint type-hint-array">Yes</a></td>
<td></td>
</tr>
<tr>
<td>id</td>
<td><a href="" class="label type-hint type-hint-string">string</a></td>
<td><p>The Id of the object to bind to</p></td>
<td><a href="" class="label type-hint type-hint-object">Yes</a></td>
<td></td>
</tr>
<tr>
<td>autoClientSave</td>
<td><a href="" class="label type-hint type-hint-boolean">Boolean</a></td>
<td><p>By default, changes in the Angular object will automatically update the Meteor object.
However if set to false, changes in the client won't be automatically propagated back to the Meteor object.</p></td>
<td><a href="" class="label type-hint type-hint-object">No</a></td>
<td><a href="" class="label type-hint type-hint-boolean">True</a></td>
</tr>
</tbody>
</table>


## Returns

<table class="variables-matrix return-arguments">
<tbody><tr>
<td><a href="" class="label type-hint type-hint-object">object</a></td>
<td><p>Newly created <a href="/api/AngularMeteorCollection">AngularMeteorObject</a> object with the following set of methods:</p>
<ul>
<li><code><span class="pln">save</span></code> — saves the current value of the object to the server.</li>
<li><code><span class="pln">reset</span></code> — reset the current value of the object to the one in the server.</li>
</ul>
</td>
</tr>
</tbody></table>


----

## Example


// Define a new Meteor Mongo Collection
Parties = new Mongo.Collection('parties');

if (Meteor.isClient) {

angular.module("socially").controller("PartyDetailsCtrl", ['$scope', '$stateParams', '$meteorObject',
function($scope, $stateParams, $meteorObject){

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

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

$scope.save = function() {
$scope.partyNotAuto.save();
};

$scope.reset = function() {
$scope.partyNotAuto.reset();
};

}]);
}

{{/markdown}}
</do-nothing>

</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h1>Step 6 - Bind one object</h1>
};


As you can see, $meteorObject return an object from type [AngularMeteorObject]() the contains 2 functions - save and reset.
As you can see, $meteorObject return an object from type [AngularMeteorObject](/api/meteorObject) the contains 2 functions - save and reset.

save() - saves the current value of the object to the server.
reset() - reset the current value of the object to the one in the server.
Expand Down
4 changes: 4 additions & 0 deletions .docs/angular-meteor/public/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@
<loc>http://angularjs.meteor.com/api/meteorCollection</loc>
<priority>0.5</priority>
</url>
<url>
<loc>http://angularjs.meteor.com/api/meteorObject</loc>
<priority>0.5</priority>
</url>
<url>
<loc>http://angularjs.meteor.com/api/collection</loc>
<priority>0.5</priority>
Expand Down

0 comments on commit 57218b8

Please sign in to comment.