Created
June 26, 2018 13:21
-
-
Save ssougnez/944656af9f8916b21e480cac72682b66 to your computer and use it in GitHub Desktop.
This file contains 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
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