'ERROR: TypeError: Cannot read properties of undefined (reading 'indexOf')
In this code, I have an error that says "Cannot read properties of undefined (reading 'indexOf')"
lowPassword(control: FormControl): {
[lowLevelPassword: string]: boolean;
} {
if (this.invalidPassword.indexOf(control.value) != -1) {
return {
lowLevelPassword: true,
};
}
return null;
}
Solution 1:[1]
invalidPassword is a array like => [{id: 1, name:'john'}] control.value is a key like => control.value = name
if there is name like key in invalidPassword array it return true otherwise false
Example:
(control.value in invalidPassword) ? 'available' : 'none'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | xenzation |
