Created
May 17, 2016 21:14
-
-
Save BooneTeam/c060e8604063fc9e3af58f51bad299c7 to your computer and use it in GitHub Desktop.
service example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Change Uncommmented stuff in BikeService.service.js | |
// Change ctrl.bikes = BikeService.all(); in dashboard.controller | |
// in index.html change dash.bikes to dash.bikes.bikes | |
var Bike = function(options){ | |
this.brand = options.brand || '', | |
this.price = options.price || 0 | |
}; | |
this.all = function () { | |
// you have to return an object for it to watch.. A plain array won't do | |
var bikes = {bikes: []}; | |
BikeResource.query().$promise.then(function(data){ | |
bikes.bikes = data.map(function(obj){return new Bike(obj)}) | |
}); | |
return bikes; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment