SHOW:
|
|
- or go back to the newest paste.
1 | function (BlockResource) { | |
2 | var collection; | |
3 | ||
4 | // initializes collection | |
5 | this.init = function () { | |
6 | collection = BlockResource.get().$promise; | |
7 | }; | |
8 | ||
9 | // gets 1 block by id | |
10 | this.getBlock = function (id) { | |
11 | if (!collection) { | |
12 | this.init(); | |
13 | } | |
14 | - | return block.id = id; |
14 | + | |
15 | return blocks.filter(function (block) { | |
16 | return block.id == id; | |
17 | }); | |
18 | }); | |
19 | }; | |
20 | ||
21 | // gets all blocks | |
22 | this.getBlocks = function () { | |
23 | if (!collection) { | |
24 | this.init(); | |
25 | } | |
26 | return collection; | |
27 | }; | |
28 | } |