I am trying to follow the documentation to access the members of an accordion from my template in my component.ts file. I'm having trouble finding out how they are accessing the members. I can't seem to get access to them. I've tried injection and @ViewChild but I can't seem to access the properties.
This is the documentation snippet I am talking about:
If you want to work with the accordion API, you can get either accordion or item instances from the template.
<div ngbAccordion #accordion="NgbAccordion"> <div ngbAccordionItem="first" #first="ngbAccordionItem" [collapsed]="false"> ... </div> </div>accordion.toggle('first'); // toggle the first item accordion.closeAll(); // close all items first.toggle(); // toggle the first item first.collapsed; // true if collapsed first.collapsed = true; // collapse the first item first.disabled; // true if disabled first.disabled = true; // disable the first item first.id; // 'first'If an item id is not provided as in the example above, it will be generated automatically in the 'ngb-accordion-item-XXX' format.
When trying to use something like first.toggle() it doesn't exist for me.
The documentation is a bit vague on this. Here is how I got it working.
The Html Template
component.html:The Typescript file
component.ts: