import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; @Component({ selector: 'app-not-found', templateUrl: './not-found.component.html', styleUrls: ['./not-found.component.css'] }) export class NotFoundComponent implements OnInit { constructor(public routerNav: Router) { } ngOnInit() { setTimeout(() => { console.log('page not found redirect to main page', this.routerNav.url); this.routerNav.navigate(['']); }, 10000); } }