I get the "Property" router "does not exist in the type" SigninComponent "." using this.router.navigate (['/ dashboard']); in angular 4

I have an import:

import { RouterModule, Routes} from '@angular/router'; 

and then I used the line below in my function inside the component

 this.router.navigate(['/dashboard']); 
+5
source share
2 answers
 /* Missing if you are using 'this.router.navigate' */ import { Router } from '@angular/router'; 
+10
source

You need to pass it inside the constructor , as shown below,

 constructor(private router: Router){ } 

Also make sure you import the Router as shown below.

 import { Router } from '@angular/router'; 
+13
source

Source: https://habr.com/ru/post/1269428/


All Articles