I am trying to use the routing through the ts code, but I am having trouble using parameters.
onSubmit(s) {
this.router.navigate(['/search', {string: 'mulher'} ]) ;
}
Routes
export const ROUTES: Routes = [
{path: '', component: AppComponent,
children: [
{ path: '', redirectTo: 'home', pathMatch: 'full'},
{ path: 'home', component: HomeComponent },
{ path: 'categoria/:id', component: ListaComponent },
{ path: 'player/:id', component: PlayerComponent },
{ path: 'search/:string', component: SearchComponent }]
}]
core.es5.js:1020 ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'search;string=mulher' Error: Cannot match any routes. URL Segment: 'search;string=mulher'
You can simply use:
this.router.navigate(['/search', 'mulher']);