【问题标题】:How to use parameters in routes with angular?如何在有角度的路线中使用参数?
【发布时间】:2018-04-08 06:09:02
【问题描述】:

我正在尝试通过 ts 代码使用路由,但是我在使用参数时遇到了问题。

onSubmit(s) {
        this.router.navigate(['/search', {string: 'mulher'} ]) ;
    }

路线

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 错误:未捕获(承诺中):错误:不能 匹配任何路线。 URL 段:'search;string=mulher' 错误:不能 匹配任何路线。 URL 段:'search;string=mulher'

【问题讨论】:

    标签: angular angular-router


    【解决方案1】:

    你可以简单地使用:

    this.router.navigate(['/search', 'mulher']);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-16
      • 1970-01-01
      • 2020-08-22
      相关资源
      最近更新 更多