Switch between components without url

angular

Solution

<component1 *ngIf="page == 1"></component1>
<component2 *ngIf="page == 2"></component2>

Where `page` is a field on the host component where you assign `1` or `2` to switch between the pages. You can also use `ngSwitchWhen`

See also Angular 2 dynamic tabs with user-click chosen components for a different approach.

Problem

Is it possible in angular to switch between two components without the need for routes? if there is how do i go about that please? I want to be switching between just two components and i don't want to use routes for that.

Original source

Related problems