Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PrimeNG Accordion doesn't work and display properly

I am try to use primeNG Accordion according to the official documentation

Here is my code:

<p-accordion [multiple]="true">
    <p-accordionTab header="Godfather I">
        The story begins  as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war, but does not intend to become part of his father's business. T hrough Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
    </p-accordionTab>
    <p-accordionTab header="Godfather II">
        Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, The_Godfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall, deepening The_Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy, killing the local Black Hand Fanucci after he demands his customary cut of the tyro's business. With Fanucci gone, Vito's communal stature grows.
   </p-accordionTab>
    <p-accordionTab header="Godfather III">
        After a break of more than  15 years, director Francis Ford Coppola and writer Mario Puzo returned to the well for this third and final story of the fictional Corleone crime family. Two decades have passed, and crime kingpin Michael Corleone, now divorced from his wife Kay has nearly succeeded in keeping his promise that his family would one day be completely legitimate.
    </p-accordionTab>
</p-accordion>

And I make sure that import { AccordionModule } from 'primeng/accordion' and import AccordionModule are in app.module.ts

Issue #1: I had an error: ERROR Error: "Found the synthetic listener @tabContent.done. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application."

Do I actually need to include BrowserAnimationsModule or NoopAnimationsModule? It is not mentioned in the official doc

Issue #2: I added NoopAnimationsModule and now the issue is gone, but the display was horrible.

It seems the accordion content and the headers are overlapped: enter image description here

one tab is active: enter image description here

Please help. Feel free to correct me if anything is misused. Thank you in advance!

like image 634
Terence Avatar asked Jul 30 '18 18:07

Terence


2 Answers

Thanks to David and Daniel in the comment section.

For issue #1: Yes, I need to import BrowserAnimationsModule

For issue #2: the primeng.min.css is missing. I have to add "/node_modules/primeng/resources/primeng.min.css" in angular.json

like image 124
Terence Avatar answered Oct 19 '22 04:10

Terence


The issue with the contents not hiding is because you don't have primeng.css included in your page, PrimeNG components automatically applies a fixed set of css classes to their components, and in your case this is the following class that is responsible for hiding the contents of your accordion panels:

.ui-accordion-content-wrapper-overflown {
    overflow: hidden;
}
like image 42
DavidZ Avatar answered Oct 19 '22 03:10

DavidZ