将数据从子模块传递到父模块Angular

时间:2018-12-17 06:25:28

标签: nested angular6 config

import { NgModule} from '@angular/core';
import { LibChildComponent } from './lib-child.component';
import { ModuleWithProviders } from '@angular/compiler/src/core';
import { LibParentModule } from 'lib-parent';

@NgModule({
  imports: [
    LibParentModule.forRoot(CONFIG)
  ],
  declarations: [LibChildComponent],
  exports: [LibChildComponent]
})
export class LibChildModule {
  static forRoot(configs: any): ModuleWithProviders {
        return {
            ngModule: LibChildModule,
            providers: [
                {
                    provide: 'LIB_CONFIG',
                    useValue: configValues,
                }
            ]
        };
    }
}

我想将配置数据从子模块传递到父模块。当数据设置为子代的forRoot方法时,则应将其设置为父代的forRoot方法。 我怎样才能做到这一点?有谁能帮助我,它会更有用。

0 个答案:

没有答案
相关问题