async/await in Angular `ngOnInit`
问题 I’m currently evaluating the pros ‘n’ cons of replacing Angular’s resp. RxJS’ Observable with plain Promise so that I can use async and await and get a more intuitive code style. One of our typical scenarios: Load some data within ngOnInit . Using Observables , we do: ngOnInit () { this.service.getData().subscribe(data => { this.data = this.modifyMyData(data); }); } When I return a Promise from getData() instead, and use async and await , it becomes: async ngOnInit () { const data = await