0
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { LmfinComponent } from '../app/lmfin/lmfin.component';
import { MfinComponent } from './mfin/mfin.component';
import { GenFunctionProvider } from './gen-function.module';
import {DetailpembayaranComponent } from './detailpembayaran/detailpembayaran.component';

const appRoutes:Routes = [                 //removed export
  {                                        //removed square bracket
    path: '',
    redirectTo: '/mfin',
    pathMatch: 'full'
  },{
     path: 'list',
     component: LmfinComponent
  },{
    path: 'mfin/:id',
    component: MfinComponent
  },{
    path: 'detailpembayaran',
    component: DetailpembayaranComponent
  }
];

@NgModule({
  imports: [
    CommonModule,
    RouterModule.forRoot(appRoutes, {useHash:true})
  ],
  declarations: []
})
export class AppRoutingModule { }

i'm still new at routing, when i try to makes routing, i got this error

ERROR Error: Uncaught (in promise): Error: Cannot match any routes.

anyone can help me please?

myura5
  • 87
  • 2
  • 14

2 Answers2

0

You default path to redirect /mfin

You no path with /mfin you have URL /mfin/:id. This is not match with /mfin

So need to add route URL of /mfin.

Mohammad Ali Rony
  • 4,695
  • 3
  • 19
  • 33
0

Try this, As far as I understood you are missing some codes in index.html. Check whether you have below code in your index.html head section. If not add it and see.

<base href="/">

Also ensure your server has configured for HTML5 pushState like explained in Angular 2.0 router not working on reloading the browser

I hope this will resolve your problem. If you have any doubts or suggestion let me know.

Suvethan Nantha
  • 2,404
  • 16
  • 28