【发布时间】:2021-10-24 01:10:02
【问题描述】:
这个*ngIf:
<div *ngIf="type === FilterType.DateRangeFilter">
...
</div>
导致错误
error TS2339: Property 'FilterType' does not exist on type 'FilterComponent
即使枚举类型FilterType 被导入到组件中:
import { FilterType } from '../filter-collection/filter-collection.component'
@Component({
selector: 'app-filter',
templateUrl: './filter.component.html',
styleUrls: ['./filter.component.css']
})
export class FilterComponent {
constructor(private type : FilterType) {
}
ngOnInit(): void {
}
}
从这里:
export enum FilterType {
DateRangeFilter, SensorSelectFilter
}
任何想法为什么这不起作用?
【问题讨论】:
-
这能回答你的问题吗? Cannot approach Typescript enum within HTML