Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 collection.then(function (blocks) {
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement