Angular 5 - 从外部文件导入组件名称和路径

时间:2018-01-20 10:21:09

标签: angular typescript angular-routing angular5

我有一个如下所示的路由模块:

import { NgModule } from '@angular/core';
import { Routes, RouterModule, Router} from '@angular/router';


// I need the data on the 2 lines below to be read from an external local file
import { OneComponent } from './one/one.component';
import { HomeComponent } from './home/home.component';

const routes: Routes = [
    { path: 'home', component: HomeComponent },
    {path: 'one', component: OneComponent}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
})

export class AppRoutingModule {}

导入此数据需要执行的操作:

import { OneComponent } from './one/one.component';
import { HomeComponent } from './home/home.component';
模块加载时从外部本地文件

(生命周期挂钩?)

我该怎么做?

0 个答案:

没有答案