Is it possible to add a directive programmatically to all elements in a component with a given class name, possibly using
document.getElementsByClassName("btn")
I want to add the matRipple
directive to all elements that use the btn
class without requiring our team to manually add the directive to every element.
Or is there another way I am missing to apply an Angular Material directive to elements of a given class or tag name (e.g. button
)
Note that this is intended for legacy apps where we do not want to switch them all to mat-button
s. The directive works fine, but I am looking for a way to make it easier for our devs.