Please check below code, I want to increment the count and based on the count I want to change the backgroundColor variable in typescript (angular). Problem is when changeColor() function is invoke count is not increment and backgroundColor is showing undefined.
export class AppComponent {
title = "angularExample";
backgroundColor = "yellow";
changeColor() {
let count = 0;
function displayNumber() {
alert(++count + this.backgroundColor);
}
displayNumber();
}
}