Outsource poems to a service

This commit is contained in:
Vit Brunner
2014-10-02 17:16:39 +02:00
parent 906f1c1af0
commit bccd8d253a
3 changed files with 36 additions and 14 deletions
@@ -0,0 +1,21 @@
angular.module("sideBySide").service "poems", ['$rootScope', '$q', 'fetch', ($rootScope, $q, fetch) ->
poems = []
heading = undefined
@update = (config) ->
fetch(config).then((result) ->
$q.all(result.promises).then((results) ->
poems = results
heading = result.heading
$rootScope.$emit "poemsLoaded"
)
)
@get = () ->
poems
@getHeading = () ->
heading
@
]