I have this piece of Javascript code:
$scope.rectifyForm =
{
visible: false,
rateErrorMessage: "",
rectifyErrorMessage: "",
isValid: function () {
return this.rateErrorMessage.length === 0 && this.rectifyErrorMessage.length === 0;
}
};
In the isValid method I want to check of both variables are set. This piece of code works because I've used the this keyword. However, If I omit this, I get an error that these variables are undefined.
Could somebody explain why this is? Why do I need to use this?