I have a module for a unique component with his own routingModule and resolver to pre-fetch data from backend. in the component's ngOnInit() I get the data passed in the route to fill a form. So if I call it with it's route, It works.
The problem is I also want to be able to load it by its selector inside a component of another external module and still pre-fetch data before loading.
the natural solution I got is to do this in the ngOnInit:
ngOnInit() {
if(comingFromRoot()) {
this.route.data.subscribe(
(data: {contactData: any}) => {
...
}
);
} else {
this.backend.getContactData().subscribe( () => ... );
}
}
is there any better solution ?