Files
side-by-side/source/documents/scripts/services/poems.js.coffee
T
2014-10-02 22:41:54 +02:00

28 lines
496 B
CoffeeScript

angular.module("sideBySide").service "poems", ['$rootScope', '$q', 'fetch', ($rootScope, $q, fetch) ->
poems = []
loaded = false
heading = undefined
@update = (config) ->
if loaded == true
$rootScope.$emit "poemsLoaded"
else
fetch(config).then((result) ->
$q.all(result.promises).then((results) ->
poems = results
heading = result.heading
loaded = true
$rootScope.$emit "poemsLoaded"
)
)
@get = () ->
poems
@getHeading = () ->
heading
@
]