Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ssougnez/944656af9f8916b21e480cac72682b66 to your computer and use it in GitHub Desktop.
angular.module("app", [])
.service("myAwesomeService", function () {
return {
doWork: function () {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve([1, 2, 3, 4, 5])
}, 2500);
})
}
}
})
.component("myAwesomeComponent", {
template: "Counter: {{ $ctrl.counter }}",
controller: function (myAwesomeService) {
var ctrl = this;
ctrl.counter = 0;
ctrl.$onInit = function () {
myAwesomeService.doWork().then(function(result) {
ctrl.counter = result.length;
})
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment