Pony.fm/public/scripts/app/services/images.coffee

26 lines
469 B
CoffeeScript
Raw Normal View History

2013-07-28 10:35:31 +02:00
angular.module('ponyfm').factory('images', [
'$rootScope'
($rootScope) ->
def = null
self =
images: []
isLoading: true
refresh: (force) ->
return def if !force && def
2013-07-28 10:35:31 +02:00
def = new $.Deferred()
self.images = []
self.isLoading = true
$.getJSON('/api/web/images/owned').done (images) -> $rootScope.$apply ->
self.images = images
self.isLoading = false
def.resolve images
return def
self.refresh()
return self
])