Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have import :

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

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

this.router.navigate(['/dashboard']);
like image 864
Prateek Jadhav Avatar asked Jul 03 '17 06:07

Prateek Jadhav


1 Answers

You need to pass it inside the constructor as follows,

constructor(private router: Router){
}

Also make sure you have imported Router as follows

import { Router } from '@angular/router';
like image 56
Sajeetharan Avatar answered Sep 19 '22 18:09

Sajeetharan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!