1

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'

1 Answer 1

1

You can simply use:

this.router.navigate(['/search', 'mulher']);
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.