mirror of
https://github.com/wassname/side-by-side.git
synced 2026-09-21 13:30:27 +08:00
Outsource poems to a service
This commit is contained in:
@@ -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
|
||||
|
||||
@
|
||||
]
|
||||
Reference in New Issue
Block a user