I have an angular component, where I define two boolean variables:
editingPercent: boolean = true;
editingCap: boolean = false;
In the corresponding html file I have a ceckbox and set this variables in the ts file accordingly:
checkedChanged(e) {
this.editingPercent = !e.value;
console.log(this.editingPercent);
this.editingCap = e.value;
console.log(this.editingCap);
}
Everything fine, the console logs false and true.
Now, I want to use this variables elsewhere in the component, in a custom validation callback like this:
capValidation(e) {
console.log(this.editingCap + ' ' + e.value);
if (this.editingCap && e.value === undefined) {
return false;
}
else { return true; }
}
But the console says, that this.editingCap
is undefined. Why?
Thanks.
ps: the validation callback will be simplified to an one row code, if I get this work properly.