0

I'm fairly new in javascript world and have a trouble with mechanism where I send variable name to function, that checks whether sent variable is set to true or not.

First of all I have got three variables:

variable: boolean = false;
variable1: boolean = false;
variable2: boolean = false;

And then from html view I call the function isChecked() this way:

isChecked('variable2')

and isChecked() function :

public isChecked(propName: string): boolean {
    return this.['propName'] == true; // but compiler here has an error, I dont know how to properly indicate to variable
}

Thanks

justme
  • 316
  • 3
  • 13

1 Answers1

0

public isChecked(propName: string): boolean { return this['propName'] == true;
}