Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropdown: requires import of BrowserAnimationsModule, which prevents Angular application from loading #14843

Closed
kponichtera opened this issue Feb 19, 2024 · 16 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@kponichtera
Copy link
Contributor

Describe the bug

Trying to open the PrimeNG dropdown fails and the following error is displayed in the console:

ERROR Error: NG05105: Unexpected synthetic listener @overlayContentAnimation.start found. Please make sure that:
  - Either `BrowserAnimationsModule` or `NoopAnimationsModule` are imported in your application.
  - There is corresponding configuration for the animation named `@overlayContentAnimation.start` defined in the `animations` field of the `@Component` decorator (see https://angular.io/api/core/Component#animations).
    Angular 5
        RuntimeError
        checkNoSyntheticProp
        listen
        listenerInternal
        listener
core.mjs:7473:22

However, importing BrowserModule and BrowserAnimationsModule (or NoopAnimationsModule) in the root module as described in https://primeng.org/installation#animations, prevents the application from loading (even though it compiles successfully), with the following error in the console:

ERROR Error: NG05100: Providers from the `BrowserModule` have already been loaded. If you need access to common directives such as NgIf and NgFor, import the `CommonModule` instead.
    Angular 53
    <anonymous> main.ts:5
core.mjs:7473:22

According to Angular documentation (https://angular.io/api/platform-browser/BrowserModule) the BrowserModule is now loaded by default for the applications, generated with the CLI. However, PrimeNG documentation does not provide information on configuring animations in the latest Angular versions, where the module is being automatically loaded. As a result, the Dropdown component is unusable.

Environment

Linux 6.7.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 17 Feb 2024 14:02:33 +0000 x86_64 GNU/Linux

Reproducer

https://stackblitz.com/edit/stackblitz-starters-apxsx8?file=src%2Fmain.ts

Angular version

17.1.0

PrimeNG version

17.7.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.11.0

Browser(s)

No response

Steps to reproduce the behavior

  1. Create a new Angular project with the CLI (with default options)
  2. Add PrimeNG by following the installation guide (https://primeng.org/installation)
  3. Add a dropdown module and dropdown components to the main component of the application
  4. Serve the Angular application and try to open the dropdown - there should be an error in the console
  5. Import BrowserModule and BrowserAnimationModule as described in the error and PrimeNG installation guide
  6. After compiling, the web application should not start anymore, and there should be an error in the console

Expected behavior

The dropdown should open without error in the console. It also shouldn't require importing BrowserModule and BrowserAnimationModule anymore. Alternatively, if that's not the case, the documentation should mention how to make the dropdown work as expected.

@kponichtera kponichtera added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 19, 2024
@manuelhumanescabrera
Copy link

Hi, i solved it using the provideAnimations function in the application config.

import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';

import { routes } from './app.routes';
import { provideAnimations } from '@angular/platform-browser/animations';

export const appConfig: ApplicationConfig = {
  providers: [provideRouter(routes), provideAnimations()]
};

If you see the function's documentation you will see that this function is for enable the animations in applications created with the function bootstrapApplication. I hope you find it helpful :)

@kponichtera
Copy link
Contributor Author

Big thanks @manuelhumanescabrera, it works as expected now! 🙏 I guess it's just PrimeNG documentation that needs updating, to account for changes in the newer Angular versions. I will create a separate issue for that later.

@bazzebazz
Copy link

@manuelhumanescabrera Genius! Saved my project♥ Thxs

@IsakkuHN
Copy link

Hi, i solved it using the provideAnimations function in the application config.

import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';

import { routes } from './app.routes';
import { provideAnimations } from '@angular/platform-browser/animations';

export const appConfig: ApplicationConfig = {
  providers: [provideRouter(routes), provideAnimations()]
};

If you see the function's documentation you will see that this function is for enable the animations in applications created with the function bootstrapApplication. I hope you find it helpful :)

U saved me <3

@Kirollosangly
Copy link

thank you @manuelhumanescabrera

@Mavi46
Copy link

Mavi46 commented Apr 8, 2024

@manuelhumanescabrera Thanks!

@stealthoust
Copy link

stealthoust commented Apr 16, 2024

@manuelhumanescabrera God bless you! I struggled with this problem for 2 days

@cronus712
Copy link

it works thanks !

@JansthcirlU
Copy link

Why doesn't this just work when CommonModule is imported by default?

@METACEO
Copy link

METACEO commented May 23, 2024

thanks @manuelhumanescabrera - it's be great if this error message could also include info for those of us using standalone components

also - please let me know how I can buy you a coffee or beer :)

@Chrinox
Copy link

Chrinox commented Jun 6, 2024

Awesome, thank you so much @manuelhumanescabrera.

@EricNeves
Copy link

Amazing, thanks manuelhumanescabrera

@wardvisual
Copy link

Hi, i solved it using the provideAnimations function in the application config.

import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';

import { routes } from './app.routes';
import { provideAnimations } from '@angular/platform-browser/animations';

export const appConfig: ApplicationConfig = {
  providers: [provideRouter(routes), provideAnimations()]
};

If you see the function's documentation you will see that this function is for enable the animations in applications created with the function bootstrapApplication. I hope you find it helpful :)

This works perfectly on my end. Thanks for sharing, @manuelhumanescabrera!

@iuliancazan
Copy link

Thank you, it works for me too!

@martin-samouiller
Copy link

Thanks!!

@vbkalmane22
Copy link

Hi, i solved it using the provideAnimations function in the application config.

import { ApplicationConfig } from '@angular/core';
import { provideRouter } from '@angular/router';

import { routes } from './app.routes';
import { provideAnimations } from '@angular/platform-browser/animations';

export const appConfig: ApplicationConfig = {
  providers: [provideRouter(routes), provideAnimations()]
};

If you see the function's documentation you will see that this function is for enable the animations in applications created with the function bootstrapApplication. I hope you find it helpful :)

You are amazing !!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests