I have an enum, and want to pass from template the enum value. How is this possible?
export enum FIELDS {
GENDER = <any>'Gender',
SALUTATION = <any>'Salutation',
FIRSTNAME = <any>'First Name',
LASTNAME = <any>'Last Name',
EMAIL_ADDRESS = <any>'Email Address',
COUNTRY = <any>'Country',
}
my template. Here i want to pass the enum value
[ngClass]="{'error':validate(FIELDS.COUNTRY)}"
//this throws an error: Unable to get property COUNTRY of undefined or null reference.
my component:
@Component({
selector: 'row-general',
template: require('./modify-invalid-row-general.component.html'),
styleUrls: ['./app/nedit/modify-invalid-row/modify-invalid-row.component.css']
})
export class ModifyInvalidRowGeneralComponent {
@Input() row: UploadRow;
@Input() columns: ConfigColumn[];
@Output() validateRow = new EventEmitter<UploadRow>();
public validate(field: string): boolean {
let invalidFields: string[] = [];
if (this.row.invalidFields != null)
invalidFields = this.row.invalidFields.split(';');
for (let i = 0; i < invalidFields.length; i++) {
if (invalidFields[i].trim() == field.trim())
return true;
}
return false;
}
if I normally call FIELDS.COUNTRY in the component I get the value 'Country'. That's what I need.
Anybody know, how can I pass the enum value?