如何在引导程序中将值从服务传递到模块的forRoot()?

时间:2018-09-05 07:31:23

标签: angular

我试图将在StateService类内部生成的数据作为单独的库模块的配置进行传递。

import { ThirdPartyIntegrationsModule } from 'third-party-integrations';
import { StateService} from './services/state.service';

@NgModule({
    imports: [
        ThirdPartyIntegrationsModule.forRoot({ deviceId: 'I want to use: StateService.deviceId' }),
        CommonModule,
    ],
    declarations: [
        AppComponent
    ],
    providers: [
        StateService
    ],
    bootstrap: [AppComponent]
})
export class AppModule { }

实现此目标的最佳方法是什么?

我尝试创建新的stateservice实例,然后使用该值-但这不起作用:

import { StateService } from './services';
const state = new StateService();

@NgModule({
    imports: [
        ThirdPartyIntegrationsModule.forRoot({ deviceId: state.trackingId }),

0 个答案:

没有答案