I use angular CLI 6 and firebase. I obtain in type script this list of array ;
(3) [Array(5), Array(5), Array(5)]
0 : (5) ["Chimiothérapie", "rettreret", 4, 1534716000000, 1535061600000]
1 : (5) ["Chimiothérapie", "trferterteretretetr", 3, 1535061600000, 1535320800000]
2 : (5) ["Chimiothérapie", "zrteretetrertertgerter", 4, 1534370400000, 1534716000000]
length: 3__proto__ : Array(0)
I want to convert the first one to this type of object :
(3) [Ppsplan, Ppsplan, Ppsplan]
0 : Ppsplan {typetraitement: "Chimiothérapie", acte: "rettreret", duree: 4, datedebut: 1534802400000, datefin: 1535148000000}
1 : Ppsplan {typetraitement: "Chimiothérapie", acte: "trferterteretretetr", duree: "", datedebut: 1534111200000, datefin: 1534111200000}
2 : Ppsplan {typetraitement: "Chimiothérapie", acte: "zrteretetrertertgerter", duree: 3, datedebut: 1535493600000, datefin: 1535493600000}
length :3
__proto__ :Array(0)
I try this :
this.ppssToDisplay2 = this.ppssService.getSinglePPS2(this.key);
this.ppssToDisplay2.subscribe((ppsList: PPS[]) => {
console.log(ppsList);
let data =[];
ppsList.map((pps: PPS) => {
Object.keys(pps.ppsplan)
.forEach(key => {
let ppsplan: Ppsplan = pps.ppsplan[key];
data.push([ ...interestingFields.map(field => ppsplan[field]) ]);
const convert_data= (list: any[]) => new Ppsplan(...list);
let ppsplans = [];
for (let list of data) {
ppsplans.push(convert_data(list));
}
});
console.log(this.ppsplans);
});
});
ERROR : expect 3 - 5 argument but got 0
Ppsplan in my interface :
export class Ppsplan {
constructor(public typetraitement:string, public acte:string, public duree:number, public datedebut = new Date() , public datefin = new Date() ) {}
}