我有一个返回数组的服务。
main(){
this.addressService.getState().subscribe( (data:any)=>{
this.usStates = data;
if(this.usStates.length===0) {
this.notificationService.showErrorNotification('Unable to get states');
console.log(this.usStates); //length of array is 10
}
});
console.log(this.usStates); //empty array
}
如何在回调范围之外获取this.usStates
的更新值?