I'm looking for an example to change CSS class of an HTML element from inside the logic of the AngularJS controller
In the controller, something like this:
function myFunc() {
//do a calculation
//result is 3
//change the class of HTML element with id="3" to add class="hidden"
I can't do it with ngClick because the controller decides which element to change, not the user.
Like if I wanted to recreate that Simon game from the 80's I would have the controller pick a random number 1-4 and then light up the HTML element and the user would have to click it in a certain amount of time.
choice = Math.floor(Math.random() * 4) + 1;
if ( choice == 2 ) {
lightUpBlue();
setTimeout(turnOffBlue();, 2000);
}
How would I write lightUpBlue()
to change the color of a button in the HTML document, and maybe change the hyperlink or some other property?
Thanks in advance.