moris62
moris62

Reputation: 1045

Cannot match any routes while want to navigate to a page

He guys

Im new in Angular,in my login page i want if the login is successful redirect to the component page which i have shown below:

  this.router.navigate(['/overview.component.html']);
  

Cannot match any routes. URL Segment: 'overview.component.html'

my overview component is :

selector: 'app-overview',
templateUrl: './overview.component.html',

should not i write the templateurl in the navigation?if so,why does it give me the error?

here is my module.ts

    RouterModule.forRoot([
                   
                      {path:'',component:LoginComponent},
                      {path:'app-events',component:EventsComponent},
                      {path:'app-turbine-comparison',component:TurbineComparisonComponent}

 ]),

Upvotes: 0

Views: 41

Answers (1)

Ross
Ross

Reputation: 126

You need to add this route to your routing module:

  RouterModule.forRoot([            
    {path:'',component:LoginComponent},
    {path:'app-events',component:EventsComponent},
    {path:'app-turbine-comparison',component:TurbineComparisonComponent}

    //Add additional route here
    {path:'app-overview', AppOverviewComponent},
 ]),

And then navigate to it like this:

  this.router.navigate(['/app-overview']);

Upvotes: 2

Related Questions