Requiero hacer un select con enumerados, en el cual se muestre un texto y el valor que almacene sea otro texto. Intenté de la siguiente manera pero obtengo el 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)
TypeScript
export enum UserRole {
STUDENT = 'Estudiante',
CAREER_DIRECTOR = 'Director de carrera',
AUTHORITY = 'Autoridad',
FINANCIAL = 'Dirección Financiera'
}
keys = Object.keys;
userRoles = UserRole;
Html (utilizo Angular-Material)
<mat-select required formControlName="role">
<mat-option *ngFor="let role of keys(userRoles)" [value]="role">
{{userRoles[role]}}
</mat-option>
</mat-select>