I am not able to change class when clicking on the button.
I am using this.
event.srcElement.classList.remove("unsubscribe");
event.srcElement.classList.add("subscribe");
I am passing the event in function when clicking on the button.
<a #subscribe title="unsubscribe" *ngIf="rec?.attributes?.Subscription == 'true'" class='unsubscribe' (click)="subscribeUnsubscribe($event);$event.stopPropagation();" data-toggle="modal"></a>
<a #subscribe title="subscribe" *ngIf="rec?.attributes?.Subscription == 'false' || rec?.attributes?.Subscription == null || rec?.attributes?.Subscription == 'undefined'" class='subscribe' (click)="subscribeUnsubscribe($event);$event.stopPropagation();" data-toggle="modal"></a>
The problem is I am having two angular components in one component the srcElement is working fine and toggling the classes, but in another component, it is not working and giving the below error.
ERROR TypeError: Cannot read property 'srcElement' of undefined