title: Ionic 4 Angular router navigate and clear stack/history of previous page
body: <p>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:</p>
  
  <pre><code>Intent intent = new Intent(NewActivity.this, MainActivity.class);
  intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  startActivity(intent);
  </code></pre>
  
  <p>From what I've read so far, it is possible using <code>Ionic NavController</code> but it is deprecating in Ionic 4. I learnt about buttons with <code>routerLink</code> 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 .</p>
  
  <p>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.</p>
  
  <p>Is there any way that I can achieve this with Angular router or do I need to rely on the deprecating Ionic NavController?</p>