Javascript 局部静态路由参数2

Javascript 局部静态路由参数2,javascript,html,angular,typescript,routing,Javascript,Html,Angular,Typescript,Routing,是否可以在角2布线中使用局部静态参数? 我要解释一下: 现在我使用的是这样的经典参数: const routes: Routes = [ { path: ':type/fine.html', pathMatch: 'full', redirectTo: ':type/fine' } const routes: Routes = [ { path: 'static-:type/fine.html', pathMatch:

是否可以在角2布线中使用局部静态参数? 我要解释一下:

现在我使用的是这样的经典参数:

const routes: Routes = [
  {
    path: ':type/fine.html',
    pathMatch: 'full',
    redirectTo: ':type/fine'
  }
const routes: Routes = [
      {
        path: 'static-:type/fine.html',
        pathMatch: 'full',
        redirectTo: 'static-:type/fine'
      }
但我可以用这样的东西:

const routes: Routes = [
  {
    path: ':type/fine.html',
    pathMatch: 'full',
    redirectTo: ':type/fine'
  }
const routes: Routes = [
      {
        path: 'static-:type/fine.html',
        pathMatch: 'full',
        redirectTo: 'static-:type/fine'
      }
能够准确地重定向到
静态-{{parameterValue}}/fine


有可能吗?

经过多次尝试,我知道做这样的事情是不可能的。因此,我使用路由保护实现了一种完全不同的方法,如下示例所示:


我只想回答任何会发现同样问题的人。

我相信这可以通过延迟加载的路由功能模块来实现,但这会很复杂。使用防护似乎是一个可靠的选择。已经尝试过延迟加载模块,但问题是相同的:您无法匹配部分静态路由。如果您尝试,您会发现使用静态和参数化路由路径的唯一方法是在两个
/
之间隔离一个参数,因为angular只将参数视为
文件夹路径或其内部。我没有意识到,这是一个非常严重的限制。您应该查看。它允许覆盖默认的匹配策略并提供您自己的匹配策略。我想它能处理好你的案子,我试过了。问题是,当UrlMatcher试图查找
:type
参数时,它只是将其视为一个字符串,并将其求值为“:type”。