【发布时间】:2016-11-02 04:43:52
【问题描述】:
我有多个不同类型过滤器的组件。 对于类型识别,我想将枚举与过滤器类型一起使用。 当下面的示例不起作用时,如何在模板中使用枚举?
我认为它应该只通过在我想使用这个枚举的组件中导入枚举来工作。
import { FilterType } from './types/FilterType';
并在模板中使用它,例如 FilterType.INPUT_SELECT 和 FilterType.INPUT_TEXT,但它不起作用,然后我使用变量,但它也不起作用。
<div *ngFor='let filter of filters'>
<select *ngIf='filter.type === checkType.INPUT_SELECT'>...</select>
<input *ngIf='filter.type === checkType.INPUT_TEXT'></input>
</div>
...
export class FiltersComponent {
checkType: FilterType;
@Input() filters: any[];
}
...
export enum FilterType {
INPUT_SELECT,
INPUT_TEXT
}
【问题讨论】:
标签: templates typescript angular angular-ng-if