Chr*_*laß 4 javascript enums angular-module typescript2.0 angular
有谁知道是否可以在 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 {
}
Run Code Online (Sandbox Code Playgroud)
为什么需要enum从modules?导出。这不是必要的 。它就像一个interfaces和classes。除了直接在templates.
您可以将它们导入到您想要的任何文件中并在那里使用。对他们来说,没有像这样的错误
未找到指令或组件