angular - 角度 ngmodule 的加载配置
问题描述
我正在platformBrowserDynamic
像这样加载配置数据:
platformBrowserDynamic([{ provide: MyConfig, useValue: new MyConfig(data.config) }])
MyConfig
是一个类:
export class MyConfig {
setting1: string;
setting2: string;
other: {}
constructor(data: any) {
this.setting1 = data.setting1;
this.setting2 = data.setting2;
this.other = data.other;
}
}
我的MyCustomModule
export function someFactoryTest() {
debugger; //<--got debugger steps here
return 'something';
}
export function initializeConfig(config: MyConfig) {
debugger; //<--debugger does not steps here and no errors in console.
return config.other;
}
@NgModule({
imports: [
MyOtherModule.forRoot(initializeConfig, someFactoryTest) //<-- I want to be able to pass my params here
],
})
export class MyCustomModule {}
我无法获取值表单MyConfig
,尝试调试,但有趣的是调试器根本没有initializeConfig
介入
你有什么想法可以解决这个问题吗?
解决方案
推荐阅读
- c# - 有没有办法等待函数中的标志更改?
- python - 在多维 numpy 数组的每个索引处切片不同的范围
- python - 用于保存数据的优秀 Python 模块
- wordpress - Wordpress 帮助(WPForms + PayPal 工作流程)
- sql - sql如何从每个用户的加入计数中获得前5名
- algorithm - 有哪些真正的迭代深度优先搜索实施建议?
- javascript - 数组的许多特定对象属性
- javascript - 在 Javascript 中使用 props.location.query 时如何提取字符串?
- python - sklearn - KNeighborsClassifier - ValueError:未知标签类型:'连续'
- regex - 正则表达式匹配选项卡或没有