I'm quite new to Typescript so I imagine this is a pretty stupid question, but I have an array of JSON objects that I want to map to a Panel
class.
When my PanelsService
class is instantiated I also want to instantiate my array of Panel
objects.
What I've got so far:
PanelsService.ts
import {Panel} from './panel';
declare var _: any;
export class PanelsService {
public panels: Array<Panel>;
public customPanels: Array<Panel>;
constructor(private _http:Http) {
this.panels = window['panels']['views'];
}
}
From this, none of my Panels
are being instantiated (I have a log in the constructor). Obviously I could loop over window['panels']['views']
and do something like this.panels.push(new Panel(myPanel)
but it seems like there must be a better way.
FWIW, my Panel
class is just a load of properties and a constructor.