Invoke a code before the ViewInit in Ionic2


#1

So I want to redirect to the profile page - if the user has already logged in once and I have some key on the localstorage.

I check for the key and redirect from the component constructor but still see a flash of the component’s view.

I tried to redirect then from the ngOnInit() and still the same behaviour.
I was checking Angular2 lifecycle methods and there is nothing like a ngBeforeViewInit() function.

I know Angular1 had that option on defining the states like to invoke something before the view loads. How are we implementing something like this in Ionic2 ??

Thanks.


#2

You could put this behavior in the app.ts.