I have followed the official documentation: https://angular.io/docs/ts/latest/guide/router.html
But when I want to navigate to LoginComponent inside the AuthGuard, I do not want to navigate inside the parent component (AppComponent) that holds router-outlet tag. I want to redirect the LoginComponent outside the parent component(AppComponent) that has router-outlet tag. As a single, stand-alone component LoginComponent, I do not want that the LoginComponent has the master html of the AppComponent.
Is this possible? how? Full example: http://plnkr.co/edit/34ajPEi1OucEXNw4L2Do?p=preview
Update: Also when I tried in the AppComponent.html to condition the router-outlet as the following:
<div *ngIf="isAuth()">
<h1 class="title">Head Router</h1>
<router-outlet></router-outlet>
</div>
<div *ngIf="!isAuth()"><app-login></app-login></div>
on the console I get the following error:
browser_adapter.ts:82EXCEPTION: Error: Uncaught (in promise): Error: Cannot find primary outlet to load 'LoginComponent'
full error example: http://plnkr.co/edit/rEEZrB?p=preview
router-outlet
insidengIf
directive and condition of ngIf equalsfalse
so your view doesn't haverouter-outlet
– yurzui