Skip to content

Commit eb3e81f

Browse files
committed
docs: add API reference, closes #53
1 parent f79cb57 commit eb3e81f

14 files changed

+990
-184
lines changed

.docs/angular-meteor/client/scripts/routes.js

+32
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,38 @@ angular.module("meteor-angular-docs").config(['$urlRouterProvider', '$stateProvi
2121
url: '/collection',
2222
template: UiRouter.template('api.collection.html')
2323
})
24+
.state('api.collection-bind', {
25+
url: '/collection-bind',
26+
template: UiRouter.template('api.collection-bind.html')
27+
})
28+
.state('api.collection-bindOne', {
29+
url: '/collection-bindOne',
30+
template: UiRouter.template('api.collection-bindOne.html')
31+
})
32+
.state('api.AngularMeteorCollection', {
33+
url: '/AngularMeteorCollection',
34+
template: UiRouter.template('api.AngularMeteorCollection.html')
35+
})
36+
.state('api.subscribe', {
37+
url: '/subscribe',
38+
template: UiRouter.template('api.subscribe.html')
39+
})
40+
.state('api.methods', {
41+
url: '/methods',
42+
template: UiRouter.template('api.methods.html')
43+
})
44+
.state('api.user', {
45+
url: '/user',
46+
template: UiRouter.template('api.user.html')
47+
})
48+
.state('api.meteor-include', {
49+
url: '/meteor-include',
50+
template: UiRouter.template('api.meteor-include.html')
51+
})
52+
.state('api.collection-pagination', {
53+
url: '/collection-pagination',
54+
template: UiRouter.template('api.collection-pagination.html')
55+
})
2456
.state('tutorial', {
2557
abstract: true,
2658
url: '/tutorial',

.docs/angular-meteor/client/styles/main.less

+101
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,105 @@ body {
115115
}
116116
}
117117
}
118+
}
119+
120+
.variables-matrix {
121+
border:1px solid #ddd;
122+
width:100%;
123+
margin:10px 0;
124+
}
125+
126+
.variables-matrix td,
127+
.variables-matrix th {
128+
padding:10px;
129+
}
130+
131+
.variables-matrix td {
132+
border-top:1px solid #eee;
133+
}
134+
135+
.variables-matrix td + td,
136+
.variables-matrix th + th {
137+
border-left:1px solid #eee;
138+
}
139+
140+
.variables-matrix tr:nth-child(even) td {
141+
background:#f5f5f5;
142+
}
143+
144+
.variables-matrix th {
145+
background:#f1f1f1;
146+
}
147+
148+
.variables-matrix td {
149+
vertical-align:top;
150+
padding:5px;
151+
}
152+
153+
.type-hint {
154+
display:inline-block;
155+
background: gray;
156+
}
157+
158+
.variables-matrix .type-hint {
159+
text-align:center;
160+
min-width:60px;
161+
margin:1px 5px;
162+
}
163+
164+
.type-hint + .type-hint {
165+
margin-top:5px;
166+
}
167+
168+
.type-hint-expression {
169+
background:purple;
170+
}
171+
172+
.type-hint-date {
173+
background:pink;
174+
}
175+
176+
.type-hint-string {
177+
background:#3a87ad;
178+
}
179+
180+
.type-hint-function {
181+
background:green;
182+
}
183+
184+
.type-hint-object {
185+
background:#999;
186+
}
187+
188+
.type-hint-array {
189+
background:#F90;;
190+
}
191+
192+
.type-hint-boolean {
193+
background:rgb(18, 131, 39);
194+
}
195+
196+
.type-hint-number {
197+
background:rgb(189, 63, 66);
198+
}
199+
200+
.type-hint-regexp {
201+
background: rgb(90, 84, 189);
202+
}
203+
204+
.type-hint-domelement {
205+
background: rgb(95, 158, 160);
206+
}
207+
208+
.return-arguments,
209+
.return-arguments th,
210+
.return-arguments th + th,
211+
.return-arguments td,
212+
.return-arguments td + td {
213+
border-radius:0;
214+
border:0;
215+
}
216+
217+
.return-arguments td:first-child {
218+
width:100px;
118219
}

.docs/angular-meteor/client/views/about.html

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ <h1>Team</h1>
1111
<li><a href="https://github.com/netanelgilad">@netanelgilad</a></li>
1212
</ul>
1313
</div>
14+
<div class="col-md-12">
15+
<h1><a href="https://trello.com/b/Wj9U0ulk/angular-meteor">Roadmap</a></h1>
16+
</div>
1417
</div>
1518
</div>
1619
</template>

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

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
<h2><a href="/api">API</a></h2>
66
<ul class="nav">
77
<li><a href="/api/collection">$collection</a></li>
8-
<li><a href="/api/step_01">$collection.bind</a></li>
9-
<li><a href="/api/step_01">$collection.bindOne</a></li>
10-
<li><a href="/api/step_02">AngularMeteorCollection.save</a></li>
11-
<li><a href="/api/step_03">AngularMeteorCollection.remove</a></li>
12-
<li><a href="/api/step_03">$subscribe.subscribe</a></li>
13-
<li><a href="/api/step_03">$methods.call</a></li>
14-
<li><a href="/api/step_03">User</a></li>
15-
<li><a href="/api/step_03">meteor-include directive</a></li>
16-
<li><a href="/api/step_03">meteor-angular-ui-router</a></li>
8+
<li><a href="/api/collection-bind">$collection.bind</a></li>
9+
<li><a href="/api/collection-bindOne">$collection.bindOne</a></li>
10+
<li><a href="/api/AngularMeteorCollection">AngularMeteorCollection</a></li>
11+
<li><a href="/api/subscribe">$subscribe.subscribe</a></li>
12+
<li><a href="/api/methods">$methods.call</a></li>
13+
<li><a href="/api/user">User</a></li>
14+
<li><a href="/api/meteor-include">meteor-include directive</a></li>
15+
<li><a href="/api/collection-pagination">Collection Pagination</a></li>
16+
<li><a href="https://github.com/Urigo/meteor-angular-ui-router">meteor-angular-ui-router</a></li>
1717
</ul>
1818
<h2><a href="https://docs.angularjs.org/api">AngularJS API Reference</a></h2>
1919
<h2><a href="https://docs.meteor.com/#/full/">Meteor Docs</a></h2>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<template name="api.AngularMeteorCollection.html">
2+
<div>
3+
<a href="https://github.com/Urigo/angular-meteor/edit/master/.docs/angular-meteor/client/views/api/api.AngularMeteorCollection.html"
4+
class="btn btn-default btn-lg improve-button">
5+
<i class="glyphicon glyphicon-edit">&nbsp;</i>Improve this doc
6+
</a>
7+
8+
<do-nothing>
9+
{{#markdown}}
10+
11+
# AngularMeteorCollection
12+
13+
An object that connects a [Meteor Collection](http://docs.meteor.com/#/full/collections) to an AngularJS scope variable
14+
15+
----
16+
17+
## Usage
18+
19+
See [bind](/api/collection-bind) and [bindOne](/api/collection-bindOne)
20+
21+
----
22+
23+
## Methods
24+
25+
<h3><p><code><span class="pln">save( :docs );</span></code></p></h3>
26+
<br>
27+
28+
#### Parameters
29+
30+
<table class="variables-matrix input-arguments">
31+
<thead>
32+
<tr>
33+
<th>Param</th>
34+
<th>Type</th>
35+
<th>Details</th>
36+
<th>Required</th>
37+
</tr>
38+
</thead>
39+
<tbody>
40+
<tr>
41+
<td>docs</td>
42+
<td>
43+
<a href="" class="label type-hint type-hint-string">empty</a>/
44+
<a href="" class="label type-hint type-hint-array">array</a>/
45+
<a href="" class="label type-hint type-hint-object">object</a>
46+
</td>
47+
<td><p>The docs to save to the Meteor Collection.
48+
If nothing is passed, the method saves everything in the AngularMeteorCollection as is.
49+
If an object is passed, the method pushes that object into the AngularMeteorCollection.
50+
If an array is passed, the method pushes that all objects in the array into the AngularMeteorCollection.
51+
</p></td>
52+
<td><a href="" class="label type-hint type-hint-object">No</a></td>
53+
</tr>
54+
</tbody>
55+
</table>
56+
57+
<br>
58+
<h3><p><code><span class="pln">remove( :keys );</span></code></p></h3>
59+
<br>
60+
61+
#### Parameters
62+
63+
<table class="variables-matrix input-arguments">
64+
<thead>
65+
<tr>
66+
<th>Param</th>
67+
<th>Type</th>
68+
<th>Details</th>
69+
<th>Required</th>
70+
</tr>
71+
</thead>
72+
<tbody>
73+
<tr>
74+
<td>keys</td>
75+
<td>
76+
<a href="" class="label type-hint type-hint-string">empty</a>/
77+
<a href="" class="label type-hint type-hint-array">array</a>/
78+
<a href="" class="label type-hint type-hint-object">object</a>
79+
</td>
80+
<td><p>The keys of the object to remove from the Meteor Collection.
81+
If nothing is passed, the method removes all the documents from the AngularMeteorCollection.
82+
If an object is passed, the method removes the object with that key from the AngularMeteorCollection.
83+
If an array is passed, the method removes all objects that matches the keys in the array from the AngularMeteorCollection.
84+
</p></td>
85+
<td><a href="" class="label type-hint type-hint-object">No</a></td>
86+
</tr>
87+
</tbody>
88+
</table>
89+
90+
<br>
91+
92+
----
93+
94+
95+
## Example
96+
97+
// Bind all the todos to $scope.todos without auto-save
98+
$collection(Todos).bind($scope, 'todos');
99+
100+
var todoObject = {name:'first todo'};
101+
var todoArray = [{name:'second todo'}, {name:'third todo'}];
102+
var todoSecondObject = {name:'forth todo'};
103+
104+
$scope.todos.save(todoObject); // todos equals [{name:'first todo'}]
105+
106+
$scope.todos.save(todosArray); // todos equals [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
107+
108+
$scope.todos.push(todoSecondObject); // The scope variable equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
109+
// but the collection still equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
110+
111+
$scope.todos.save(); // Now the collection also equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
112+
113+
$scope.todos.remove(firstTodoId); // scope and collection equals to [{name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
114+
115+
$scope.todos.remove(todoIdsArray); // removes everything matches the array of IDs both in scope and in collection
116+
117+
$scope.todos.pop(); // removes only in scope
118+
119+
$scope.todos.remove(); // syncs also in Meteor collection
120+
121+
{{/markdown}}
122+
</do-nothing>
123+
124+
</div>
125+
</template>

0 commit comments

Comments
 (0)