Angular 2 events fire twice
I have built my app with angular 2 and ionic. My app contains about 15 different components that are lazy loaded, when I open it I send some data to the component.
Each component uses an extension class without binding a component to it (just a regular class).
If I load one of these components, the constructor and lifecycle events fire twice, causing the data to be empty a second time. However, if I load the same component again, it doesn't fire twice. If I load another component it fires twice, if I go back to the first component already loaded after the events fire twice.
Does anyone know what I am doing wrong here?
Edit: all "run" -lifecycle events fire twice, even the class constructor. I have registered all events, ngOnInit, ngAfterContentInit and Ionics as ionViewDidLoad, ionViewWillEnter.
I made a very very UGLY fix and hope I can solve it better, on the first load I set the data to a global variable and on the second load I get this variable instead of params.
source to share
No one has answered this question yet
Check out similar questions: