In footer.component
signIn() {
const el = this.elRef.nativeElement.querySelector('.UserTrigger');
console.log(el); // null
el.dispatchEvent(new Event('click'));
}
--
<a (click)="signIn()">Sign In</a>
In header.component.html
<div #userTrigger class="UserTrigger" (click)="loginModal()">Sign In</div>
Question
In the above I am trying to click the login button in the footer which will trigger the signin modal which lives in the header. I know i can just reference the the modal in the footer but thats not what i want.
How do I access elements from another component?
loginModal()public method on that component.