The thing you need to know about promises, is that they are wrapping code that happens asynchronously. That is, outside of the normal control flow of your program. It is quite straightforward to set a continuation function on a promise as a callback to then() to register code to be run after the promise has resolve like below:
function doSomething(result) {
// some code
}
myPromise.then(doSomething).then((result) => {
doAnotherThingInAnAnonymousFunction();
console.log(result);
console.log('this happens after doSomething()');
});
It can take a little getting used to using continuation functions in this manner. If you want to jump ahead and get right to something that is more familiar to you, you can just wrap your code in an async/await pattern and it will appear to work just like your asynchronous code (but believe me, it's using Promises and continuation functions under the hood).
async function doAsyncStuff() {
const result = await service.getStuff();
scope.stuff = result['mine'];
console.log(scope.stuff); // this is up to date because of the await above
}
Read on for more information: https://www.oreilly.com/library/view/you-dont-know/9781491905241/ch04.html
This stuff is rather central to JS development and I suggest you take some time on it.