I need to make a select with enum, in which a text is shown and the value that it stores in another text. I tried as follows but I get the error:
Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'typeof UserRole'. No index signature with a parameter of type 'string' was found on type 'typeof UserRole'.ngtsc(7053)
Html (Angular-Material)
export enum UserRole {
STUDENT = 'Estudiante',
DIRECTOR = 'Director de carrera',
AUTHORITY = 'Autoridad',
FINANCIAL = 'Dirección Financiera'
}
keys = Object.keys;
userRoles = UserRole;
TypeScript
<mat-select required formControlName="role">
<mat-option *ngFor="let role of keys(userRoles)" [value]="role">
{{userRoles[role]}}
</mat-option>
</mat-select>