Cannot approach Typescript enum within HTML

前端 未结 5 441
生来不讨喜
生来不讨喜 2021-01-31 13:03

I made an enum with Typescript to use in MyService.service.ts MyComponent.component.ts and MyComponent.component.html.

export enum ConnectionResult {
    Succes         


        
5条回答
  •  野的像风
    2021-01-31 13:36

    You can just add the enum to your component as property and use the same name of the enum (Quarters) in your templates:

    enum Quarters{ Q1, Q2, Q3, Q4}
    
    export class AppComponent {
       quarter = Quarters.Q1
       Quarters = Quarters
    }
    

    In your template

    I=am only visible for Q1

    The reason why this works is that the new porperty is basically of this type:

    TileType: typeof TileType
    

提交回复
热议问题