如何从另一个模块angular2获取一个组件

时间:2016-12-15 09:55:44

标签: angular typescript angular-ui-router

在角度2中如何从其他模块导入特定组件

在home.module.ts j我需要导出并导入到其他模块tranfer.module.ts 导入homeModule后点击转移页面显示主页   如何获得特定组件?

appComponent

tranfer.module.ts

 import { NgModule }      from '@angular/core';
    import { CommonModule }  from '@angular/common';
    import { FormsModule } from '@angular/forms';
    import { NgaModule } from '../../theme/nga.module';

    import { routing }       from './home.routing';
    import { homeComponent } from './home.component';
    import { recharge } from './recharge';
    import { mobile } from './mobile/mobile.component';
    import { appComponent } from './appComponent/appComponent.component';
    import { appService } from './appComponent/appComponent.service';

    @NgModule({
      imports: [
        CommonModule,
        FormsModule,
        NgaModule,
        routing
      ],
      declarations: [
        recharge,
        mobile,
        appComponent,
        homeComponent
      ],
      providers: [
        appService
      ],
      exports: [
            appComponent
      ]
    })
    export default class homeModule {}

home.routes.ts

import { NgModule }      from '@angular/core';
import { CommonModule }  from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgaModule } from '../../theme/nga.module';

import { routing }       from './tranfer.routing';
import  homeModule from '../home/home.module';
import { tranfer } from './tranfer.component';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    NgaModule,
    homeModule,
    routing
  ],
  declarations: [
    tranfer
  ]
})

0 个答案:

没有答案