I created a static array in the class in typescipt. But I couldn't read its property.
The error is shown below.
ERROR TypeError: Cannot read property 'forbiddenProjectNames' of undefined
Here is my code snippet shown below.
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;
}
}
How can I fix it?
static? At least for the property it does not make sense, because you mark it as private anyway, so you don't want to instatiate it from outside.