[Angular] Accordion breaking on *ngFor on accordion-child #2060
Replies: 2 comments
-
Hi! My guess is that at the moment of calling the |
Beta Was this translation helpful? Give feedback.
-
I conceded to solution below, adding the The reason that export class TeInitiatorComponent implements OnInit, AfterViewInit, AfterViewChecked {
constructor() { }
ngOnInit() {
initTE({ Button, Ripple, Dropdown, Collapse});
}
ngAfterViewInit() {
initTE({ Button, Ripple, Dropdown, Collapse});
}
ngAfterViewChecked() {
initTE({ Button, Ripple, Dropdown, Collapse});
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm looking at creating accordion items dynamically in Angular 13+. For achieving this, I'm using the following template:
custom-accordion.component.ts
(Note the *ngFor in this template)
The idea is to create a custom angular component that implements TWElements accordion, and is customizable with title and content based on the object sent to the custom component but also dynamic in the way that the amount of accordion-children can be applied using *ngFor.
But when i try using the above html, the children render, but their collapse function is not working. I suspect that
initTE();
does not find the attributes it needs to initiate collapse. And if this is the case I want to refer to following discussion:[Angular] Dealing with angular routing and initTE()?
Where the issue was that
Button
was not initiated because theinitTE()
could not find the attributes it need to initiate.Question is, how do i make the
initTE();
initiate the accordionCollapse
functionality now if the children are rendered dynamically?P.S
It does not work even if i add
initTE();
in the AfterViewInit() lifecycle in the very same.ts
-file as above template is in.P.S.S
It works if I add an accordion without the *ngFor. Which makes me think that it now sees an attribute it needs to initiate.
Beta Was this translation helpful? Give feedback.
All reactions