When attempting to update the array value, I am encountering an issue where it works inside the httpClient method but not outside of it. How can this be resolved in Angular 14?
Here is a snippet from app.component.ts:
ngOnInit(): void {
this.httpClient.get<string[]>('../assets/data.json').subscribe((data) => {
this.groupData = data;
console.log(this.groupData); // should display data.json value
});
}
You can view a demo here.