when the page first loads I want to navigate to /login or /signup depending on localStorage value. but I don't want to render anything before navigating to one of those. I have this in app.component.ts:
import { Component } from '@angular/core'; import {Router} from "@angular/router"; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { constructor( private router: Router ) {} getStoredEmail(){ return localStorage.getItem('email') } ngOnInit(): void{ if(this.getStoredEmail()){ this.router.navigate(['/login']) } else { this.router.navigate(['/signup']) } } } is this the right approach? the problem is that it will render the app component before rendering the login or signup component? -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/995bff0d-0f8a-4a2e-9d42-61c4159568edn%40googlegroups.com.