【问题标题】:How to change variable at module with angular schematics?如何使用角度示意图更改模块中的变量?
【发布时间】:2021-12-18 13:40:01
【问题描述】:

就像addImportToModuleaddProviderToModul一样,我的模块文件如下所示:

const EXAMPLES = [
    ButtonIconExampleComponent,
    ButtonTextExampleComponent,
    ButtonDashedExampleComponent
]

@NgModule({
    declarations: EXAMPLES,
    imports: [CommonModule],
    entryComponents: EXAMPLES,
    exports: EXAMPLES,
    providers: []
})
export class ExamplesModule {}

变量EXAMPLES可以多次使用,所以我想用schematics utils函数来改变它。

【问题讨论】:

    标签: angular angular-schematics


    【解决方案1】:

    您可以通过使用export 将其导出为全局变量,然后您可以在.ts 文件中的任何位置使用它。

    【讨论】:

    • 好吧,但我只需要在运行原理图时将变量推送到const EXAMPLES
    猜你喜欢
    • 2018-12-24
    • 2021-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-19
    • 2021-05-07
    • 2011-04-01
    相关资源
    最近更新 更多