如何在angular 2或>;中保持URL中的尾随斜杠;儿童路线?

如何在angular 2或>;中保持URL中的尾随斜杠;儿童路线?,angular,typescript,angular2-routing,trailing-slash,Angular,Typescript,Angular2 Routing,Trailing Slash,我想知道如何在角度布线中强制使用最终斜杠。 我使用这种方法来维护Angular应用程序中的最终斜杠,我使用了此文档 另外,在WizardComponent中,我有一个路由器出口 我在定义路径“page-childs”时遇到问题,因为我需要在末尾加上斜杠,如果我在定义中加上它(“page-childs/”),路由将停止工作 有人知道我应该如何定义这个吗 export const contactUsRoutes: Routes = [ { path: 'contact-us/

我想知道如何在角度布线中强制使用最终斜杠。 我使用这种方法来维护Angular应用程序中的最终斜杠,我使用了此文档

另外,在WizardComponent中,我有一个路由器出口

我在定义路径“page-childs”时遇到问题,因为我需要在末尾加上斜杠,如果我在定义中加上它(“page-childs/”),路由将停止工作

有人知道我应该如何定义这个吗

export const contactUsRoutes: Routes = [
    {
        path: 'contact-us/.', component: ContactUsComponent
    }
];

<a [routerLink]="['/contact-us/.']">Contact us</a>

import { Location } from '@angular/common';

// main.ts
const __stripTrailingSlash = (Location as any).stripTrailingSlash;
(Location as any).stripTrailingSlash = function _stripTrailingSlash(url: string): string {
  const queryString$ = url.match(/([^?]*)?(.*)/);
  if (queryString$[2].length > 0) {
    return /[^\/]\/$/.test(queryString$[1]) ? queryString$[1] + '.' + queryString$[2] : __stripTrailingSlash(url);
  }
  return /[^\/]\/$/.test(url) ? url + '.' : __stripTrailingSlash(url);
};
const wizardRoutes: Routes = [{
  path: 'page-childs',
  component: WizardComponent,
  children: [
    {
      path: '',
      component: Page1Component,
    },
    {
      path: ':region/.',
      component: Page2Component,
    },
    {
      path: ':region/:origins/.',
      component: Page3Component,
    }
  ]
}];
// main path:  localhost/page-childs/    redirecto to Page1Component
// path Child 1:  localhost/page-childs/usa/    show Page2Component
// path Child 2:  localhost/page-childs/usa/aaa/    show Page3Component