私はAngularアプリケーション全体でルート文字列をハードコードしていることに少し気を付けています。それはちょっと間違っているようです!例えば角度経路 - ハードコードされた文字列を避ける
this._router.navigate(['dashboard/customer', customer.CustomerId]);
path: 'customer', component: CustomerComponent,
これを回避する方法はありますか?その後、アプリからこれを通じ使用
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
// import of customer component
const routes: Routes = [
{
path: 'customer', pathMatch: 'full', component: CustomerComponent
}
// More routes ...
{
path: '**',
redirectTo: '/not-found'
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class RoutingModule { }