问题描述
export function toCamelCase(string): string {
//code omitted
}
import * as utility from '../shared/functions/helper-functions';
但是,我使用共享模块,我想知道是否可以将此辅助函数引用仅添加到共享模块并将其导出,以便我可以在不添加其引用的情况下使用其函数(我已经添加了 shared.module 引用)。有什么想法吗?
import * as utility from '../shared/functions/helper-functions';
@NgModule({
declarations: [
//...
],imports: [
//...
],exports: [
// I want to add helper function as a module
],providers: [
//...
})
export class SharedModule { }
解决方法
也只有 export class SharedModule
和 export * from '../shared/functions/helper-functions'
。
如果您真的想在 Angular 模块中公开辅助函数,您可以将它们公开为服务(在 providers
部分中),但这实际上没有意义。