I'm developing an app using Ionic 4 with Angular router. I would like to navigate to another page and clear the page stack. In Android native, it's something like this:
Intent intent = new Intent(NewActivity.this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
From what I've read so far, it is possible using Ionic NavController
but it is deprecating in Ionic 4. I learnt about buttons with routerLink
but if I'm not mistaken, by using that the app will immediately navigate to the other page. I need to execute some logic before navigating to another page .
For example: Login page. After successful login, the user shouldn't be able to go back to the login page. Also, by clicking the 'login' button, it should call a function to process the login and decide to navigate/not navigate to another page.
Is there any way that I can achieve this with Angular router or do I need to rely on the deprecating Ionic NavController?
NavController
for this issue. its not fully deprecated, you can still use it. or else you can useionViewWillLeave()
to empty your stack. – Najam Us SaqibNavController
for now – tyn