Ankit kaushik
Nov 10, 2023

In most cases ViewChild is completely avoidable, as in your case. (Directly refer and access it in the template):

<app-accordion #accordion>

<ng-container accordion-header>

<div class="flex justify-between">

<p>Accordion Header Title</p>

<button (click)="accordion.toggleCollapsedStatus()" >

Accordion Trigger</button>

</div>

</ng-container>

<ng-container accordion-body>

<!-- Accordion Body -->

</ng-container>

</app-accordion>

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Ankit kaushik
Ankit kaushik

Written by Ankit kaushik

Frontend Tech Lead, Angular Expert

No responses yet

Write a response