I encountered an issue while trying to access a property of a static array that I created in a TypeScript class.
The error message I received is as follows:
ERROR TypeError: Cannot read property 'forbiddenProjectNames' of undefined
Below is the code snippet where I defined the array:
export class CustomValidator {
private static forbiddenProjectNames = ['Test'];
static forbiddenNames(control: FormControl): {[s: string]: boolean} {
if (this.forbiddenProjectNames.indexOf(control.value) !== -1) {
return { 'nameIsForbidden': true };
} else {
return null;
}
}
Any suggestions on how I can resolve this issue?