I use angular CLI, angularFire and Firebase.
I have this data in realdatabase :
I get data from firebase with an observale :
//Service.ts
import { Injectable } from '@angular/core';
import { Patient } from '../models/patient.model';
import {PPS } from '../models/pps.model';
import { AngularFireDatabase, AngularFireList, AngularFireObject} from 'angularfire2/database';
@Injectable({
providedIn: 'root'
})
export class PPSsService {
ppss: AngularFireList<any>;
constructor(private database: AngularFireDatabase) {this.ppss = database.list('ppss');}
getPPSByPatientid(Patientid: string){
return this.database.list('/ppss', ref => ref.orderByChild("Patientid").equalTo(Patientid)).valueChanges();
}
}
// component.ts
export class PpsComponent implements OnInit {
patientid: string;
patientToDisplay;
diagnosticsToDisplay;
ppssToDisplay;
traitement: string;
data1: any[];
config1: GanttChartConfig;
elementId1: string;
constructor(
private route: ActivatedRoute,
private location: Location,
private patientsService: PatientsService,
private diagnosticsService: DiagnosticsService,
private ppssService: PPSsService,
private router: Router,
public dialog: MatDialog,
){ }
ngOnInit() {
this.route.params.forEach((urlParameters) => {
this.patientid = urlParameters['id']; });
this.patientToDisplay = this.patientsService.getSinglePatient(this.patientid);
this.diagnosticsToDisplay = this.diagnosticsService.getDiagnosticByPatientid(this.patientid);
this.ppssToDisplay = this.ppssService.getPPSByPatientid(this.patientid);
console.log(this.ppssToDisplay);
this.data1 = [[ 'traitement','start', 'end'],
[ 'Chirurgie', new Date(2017, 3, 29), new Date(2017, 3, 30)],
[ 'Chimiothérapie', new Date(2017, 2, 4), new Date(2018, 2, 4)],
[ 'Radiothérapie', new Date(2017, 2, 4), new Date(2018, 2, 4)]];
this.config1 = new GanttChartConfig('', '', '',new Date (),new Date ());
this.elementId1 = 'myGanttChart';
}
And i can display data in my tamplate...
But now i need in my component.ts an array like that :
this.ppssToDisplay = [['typetraitement', 'traitement','datedebut', 'datefin']]
I try to replace data1 by your code but i have an error ppssToDisplay.map is not a fonction...