如何使参数化路由工作

How to get Parameterized routes working

我可能只是遗漏了一些明显的东西,但我无法使 :id*id 工作。

这是我正在使用的路由配置:

{
  route: 'char/:id',
  name: 'char',
  moduleId: 'modules/char/char',
  href: "char"
}

这是我在 char.ts:

中得到的代码
export class Char {
  activate(params: {id: string}) {
    console.log(params.id);
  }
}

现在我似乎无法从地址栏为 id 赋值。 这个的语法是什么?

(我也试过使参数可选,:id? 但仍然没有)

原来我从一开始就有点倒退了。
这是有效的:

http://localhost:9000/#char/foobar

那么 id 将等于 foobar.