Ole Ersoy

Feb 4, 2021

1 min read

Using Enum Values in Angular Templates

Image by Willgard Krause from Pixabay

Scenario

export enum SocialMediaType {
TWITTER,
FACEBOOK,
LINKEDIN
}
<fs-social-icon [topic]="topic" [type]="SMT.TWITTER"></fs-social-icon>

Approach

public SMT = SocialMediaType;
<fs-social-icon [topic]="topic" [type]="SMT.TWITTER"></fs-social-icon>

Demo

Brought to You By