Within my component, I have created a variable as an array called info[], with the intention of dynamically assigning values based on data from a service.
export class CostsComponent implements OnInit {
public info: any[] = [];
constructor(private deliverablesService: DeliverablesService, private setupcostsService: SetupcostsService, private activatedRoute: ActivatedRoute) { }
ngOnInit() {
this.activatedRoute.params.subscribe((params: Params) => {
this.setupcostsService.getcostDetails(2940).subscribe(
data => {
this.info.col = data.col; // dynamic
this.info.data = data.data; //dynamic
console.log('cost Info',data);
},
() => { }
);
});
}
When attempting to set this.info.col
, it results in the error message '
Property 'col' does not exist on type 'any[]'
'.