Files
side-by-side/source/documents/scripts/services/poems.js.coffee
T
2014-10-12 14:30:19 +02:00

31 lines
587 B
CoffeeScript

angular.module("sideBySide").service "poems", ['$q', 'fetch', ($q, fetch) ->
@all = [{
meta: {
Active: true
}
content: [{
section: 'Loading...'
text: 'Please be patient!'
}]
}]
@heading = undefined
@getActive = () ->
(poem for poem in @all when poem.meta.Active is true)
@load = (base = '') =>
config = base + "/config.json"
fetch(config).then (result) =>
$q.all(result.promises).then (results) =>
@all = []
for poem in results
if not poem.meta.Active?
poem.meta.Active = true
@all.push poem
@heading = result.heading
@
]