I'm working with angular2 rc1. I'm working on a simple game that starts with a menu screen and when clicking on a menu button I would like to navigate to a different view, replacing the current view. I then would like to navigate back with a back button.
This is a seemingly simple requirement, however, all routing samples I see using the router-outlet append to the current view instead of replacing it. e.g.
<h1>Component Router</h1>
<nav>
<a [routerLink]="['/crisis-center']">Crisis Center</a>
<a [routerLink]="['/heroes']">Heroes</a>
</nav>
<router-outlet></router-outlet>
This markup appends the new view under the </nav>
element.
Am I missing something obvious? Is there a simple way to do this or do I need to use the <router-outlet>
in combination with an *ngIf
to hide the current view?
Component Router
` – Jeffry van de Vuurst May 08 '16 at 16:38