I'm using InMemoryDbService in Angular app. Some field of model is custom type.
The following field is array of classes:
public FlightQuotes: CFlightClassQuote[];
The following is initialization of this field:
const cf = new Array<CFlightClassQuote>();
cf[0] = new CFlightClassQuote();
cf[0].Class = 'A';
cf[0].ClassName = 'B';
cf[0].FreeBack = 2;
cf[0].FreeDirect = 5;
cf[1] = new CFlightClassQuote();
cf[1].Class = 'C';
cf[1].ClassName = 'D';
cf[1].FreeBack = 3;
cf[1].FreeDirect = 6;
......
......
const model = new MyModel();
model.FlightQuotes = cf;
Before asking this question i was search but without result. I'm not familiar with typescript syntax. Can i write shortly initialization of this array? Maybe something like in this:
model.FlightQuotes = [new CFlightClassQuote{Class = 'A'}, new CFlightClassQuote {Class = 'B'}];