Как запустить ngOnInit компонента A, когда я вызываю функцию этого компонента A?
Например:
export class CompositionComponent implements OnInit {
measure = new MeasureComponent(this.http);
constructor(private http: HttpClient) { }
myFunction(){
measure.functionMeasure();
}
//
export class MeasureComponent implements OnInit {
configCompo;
constructor(private http: HttpClient) { }
ngOnInit() {
this.getConfigCompo().subscribe(data => {
this.configCompo = JSON.parse(data);
});
functionMeasure(){
console.log(this.configCompo)
}
, нона самом деле this.configCompo не инициализируется, когда я вызываю эту функцию из Composition Component, потому что она инициализируется в ngOnInit ()