Skip to content

Instantly share code, notes, and snippets.

@BooneTeam
Created May 17, 2016 21:14
Show Gist options
  • Save BooneTeam/c060e8604063fc9e3af58f51bad299c7 to your computer and use it in GitHub Desktop.
Save BooneTeam/c060e8604063fc9e3af58f51bad299c7 to your computer and use it in GitHub Desktop.
service example
// 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