I received a handwritten array to populate a table for my class, however I am now fetching this array's content from a JSON during the ngOnInit phase and it is not structured in the way I require.
Therefore, I am attempting to create a function that will update the table array with this new data retrieved during the ngOnInit phase.
The problem arises when I attempt to write code outside of a function in my Typescript class, as I encounter an error stating "Function implementation is missing or not immediately following the declaration".
What could be causing this issue and how can I resolve it?
Typescript
export class MyComponent implements OnInit {
users: Object;
constructor(private tstService: MyComponentService) {
this.source = new LocalDataSource(this.data);
}
ngOnInit(): void {
this.tstService.getTstWithObservable()
.map(result => result.map(i => i.user.data))
.subscribe(
res => { this.users = res; }
);
console.log(this.users); // This line is just an example. It throws 'Function implementation is missing or not immediately following the declaration'
data = [
{
title: 'Monthly',
sdate: '01/04/1990',
edate: '30/09/1990',
},
];
source: LocalDataSource;
}