When I awaited an array of items from the API it successfully received and assigned to the variable.
async ngOnInit(): Promise<void> {
this.items = await this.apiService.getItems().toPromise();
}
But when I try to call it from another function, which for example, assigned to click event in the template, it received empty.
getSomeValue() {
var value = this.items;
}
this.items
is an empty array at that time. Why this happens and how to work around it?