I've been having trouble with a very basic task... I need to assign a class to a <div>
when I click on a button
. After hours of searching online, I still haven't found a simple solution and all the examples I come across are too complex for my needs.
What I want to do is as straightforward as this (jquery) code in angular2/typescript:
$(".button").click(function() {
$(".element").addClass("active");
});
In my component folder, I have the usual html, scss, and ts files. This functionality doesn't need to be global or anything complicated.
It's frustrating how something so simple has become difficult to achieve with modern frameworks. Any assistance would be greatly appreciated!