Skip to content

Instantly share code, notes, and snippets.

@xcarpentier
Created October 21, 2014 21:56
Show Gist options
  • Save xcarpentier/81131e03d82a6f5a804a to your computer and use it in GitHub Desktop.
Save xcarpentier/81131e03d82a6f5a804a to your computer and use it in GitHub Desktop.
/* A éviter */
function Avengers(dataservice) {
var vm = this;
vm.avengers = [];
vm.title = 'Avengers';
dataservice.getAvengers().then(function(data) {
vm.avengers = data;
return vm.avengers;
});
}
/* Recommandé */
function Avengers(dataservice) {
var vm = this;
vm.avengers = [];
vm.title = 'Avengers';
activate();
////////////
function activate() {
return dataservice.getAvengers().then(function(data) {
vm.avengers = data;
return vm.avengers;
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment