How can I use ngFor to iterate over Typescript Enum as an array of strings

后端 未结 11 1626
借酒劲吻你
借酒劲吻你 2020-12-13 12:03

I am using Angular2 and Typscript. I have an enum:

export enum Role {
    ServiceAdmin, CompanyAdmin, Foreman, AgentForeman, 
    CrewMember, AgentCrewMembe         


        
11条回答
  •  甜味超标
    2020-12-13 12:41

    After further research and review of the other answers I now can formulate an answer to my question. I think its not possible to just use *ngFor to iterate over an enum without some code support in the component. The code support can consist of constructor code that turns the Enum into some sort of array or we can create a custom pipe that does something similar.

提交回复
热议问题