【发布时间】:2018-03-07 06:11:18
【问题描述】:
有谁知道是否可以在 Angular 模块中导出枚举? 如果没有,是否有在 Angular 模块中发送枚举的最佳实践?
// not working example
// i dont know how to export GreatEnum
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { GreatComponent } from './great.component';
import { GreatEnum } from './great.enum';
@NgModule({
imports: [
CommonModule
],
declarations: [GreatComponent ],
exports: [GreatComponent ]
})
export class GreatModule {
}
【问题讨论】:
-
显示你的枚举文件
-
你认为你需要导出什么?为什么要使用 DI 注入它?
-
在使用
index.ts桶文件时可以直接使用 -
枚举文件看起来像:export enum GreatEnum { 'foo' = 1, 'bar' = 2 }
标签: javascript angular enums typescript2.0 angular-module