I have a component SurveyComponent
and a service SurveyService
. The SurveyService
loads some data form JSON.
I add the SurveyService
into the constructor from SurveyComponent
.
constructor(public surveyService: SurveyService) {}
In the constructor from SurveyService
I load some data.
constructor(private storageService: StorageService) {
this.finishedSurveys = [];
this.loadCurrentSurvey();
this.loadFinishedSurveys();
}
I put also the SurveyService
into the app.module
:
.....providers: [SurveyService].....
But the component loads before service so I haven no data in my component. Why does it happen? Can I solve this issue?