2
votes

I learned from many prestigious site (e.g. twitter, twitch, facebook), they all serve the root route for both authorised and unauthorised user. Says for twitter, the url location points to https://twitter.com before and after user login.

Angular router seems to offer only static configuration such that i can't create component dynamically based on authentication logic inside the canActivate guard. What i can only do is to navigate (e.g. this.router.navigate(['/login'])) to different path that angular then will instantiate the corresponding component but then i will be not in the root anymore.

Any idea of how to achieve the above pattern for angular router? Thanks a lot!

1

1 Answers

0
votes

if use a *ngIf you can change complety the same page. In "pseudo-code"

<div *ngIf="!authenticate">
   login
</div>
<div *ngIf="autenticate">
    <div ngFor="let post in postAutenticate">
    </div>
</div>