Skip to content

Instantly share code, notes, and snippets.

@awilson28
Last active December 8, 2015 17:53
Show Gist options
  • Save awilson28/443bc354599425b9b891 to your computer and use it in GitHub Desktop.
Save awilson28/443bc354599425b9b891 to your computer and use it in GitHub Desktop.
app.factory('AlbumFactory', function(DS){
var AlbumFactory = DS.defineResource({
basePath: 'api',
name: 'albums',
idAttribute: '_id',
methods: {
raw: function(){
return 'api/albums/'+ this._id + '.image'
}
}
})
return AlbumFactory;
})
.controller('AlbumController', function(AlbumFactory){
// GET to 'api/albums'
AlbumFactory.findAll()
.then(function(albums){
var firstAlbum = albums[0]
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment