Error when refreshing child routes, Angular 4

隐身守侯 提交于 2019-12-12 05:47:07

问题


I'm using PathLocationStrategy and the <base href="/"> in index.html. when I go into a child routes like product-detail if I try to refresh the page I get Error: Cannot match any routes, also if I go back and forward with browser. Do I need to switch to HashLocationStrategy to handle refresh?

This is child routes.

import { Route } from '@angular/router';
import { CustomerDetailComponent } from './index';

export const CustomerDetailRoutes: Route[] = [
  {
    path: 'customer-detail/:code',
    component: CustomerDetailComponent
  },
];

And this is parent routes

import { DashboardComponent } from './index';

export const DashboardRoutes: Route[] = [
    {
      path: 'dashboard',
      component: DashboardComponent,
      children: [
        ...HomeRoutes,
        ...HotelRoutes,
        ...UserDetailRoutes,
        ...TicketTypeRoutes,
        ...TicketBlockRoutes,
        ...TransitCertificateRoutes,
        ...TemplateDetailRoutes,
        ...DepositReceiptRoutes,
        ...TemplateRoutes,
        ...LicensePlateDetailRoutes,
        ...DepositReceiptDetailRoutes,
        ...LicensePlatesRoutes,
        ...CustomerDetailRoutes,

      ]
    }
];

来源:https://stackoverflow.com/questions/45140399/error-when-refreshing-child-routes-angular-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!