i want the first button to be clicked right when the page loads im building it using html,css, typescript
<div class="media-column">
<!-- posts button -->
<button #postsButton class="media-button"(click)="applyFilter('posts')">
<span class="media-label">Posts</span>
</button>
<!-- images button -->
<button class="media-button"(click)="applyFilter('images')">
<span class="media-label">Pictures</span>
</button>
<!-- videos button -->
<button class="media-button" (click)="applyFilter('videos')">
<span class="media-label">Videos</span>
</button>
</div>
i tried but it didnt work, i didnt getthe button clicked
@ViewChild('postsButton', { static: true }) postsButton!: ElementRef;
ngOnInit() {
this.postsButton.nativeElement.click();
}
You need to sign in to view this answers
Leave feedback about this