I have a function that get's the user's input. Inside that function, is a callback function that checks the user's input. When calling the call back function, i get an error, ERROR Error: Cannot read property 'input' of undefined.
HTML
<input id="answer" type="number" (input)= "getInput($event, checkAnswer)" >
JS
input = null;
answer = null;
getInput(event, chkAns){
this.input = Number(event.target.value);
chkAns();
console.log("Input :" + " " + this.input);
}
checkAnswer(){
if(this.input === this.answer){
this.multiply();
} else{
console.log(this.input + " " + "is incorrect" + " " + typeof
this.answer);
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…