简体   繁体   中英

How to enable Angular animations?

I've done everything by the tutorial ( https://angular.io/guide/animations ), but I have the error: menu-navigation.component.html:1 ERROR Error: Found the synthetic property @slideTop. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application. menu-navigation.component.html:1 ERROR Error: Found the synthetic property @slideTop. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.

I read everything about it but did not find the answer on how to resolve it.

Files:

So I did:

  • Imported animation modules in the root module (and added them into imports section)
  • Described animation of the animated element
  • Defined attribute about animation
  • Did everything according to documentation

I tried:

  • Replace BrowserAnimationsModule with NoopAnimationsModule: no result
  • Replace "data: boolean" with "data: any" (in parent component): no result
  • Check all NPM-modules versions: they are all 8.0.0 version, no result
  • Check tutorial steps many times: no result
  • Copy animation metadata from the tutorial and do everything like there, and still: no result

Guys, help me :) I am stuck for already a few days.

UPDATE: Finally, I found the answer after testing on a new empty project

If you defined "animations" to the component (prop), then you can use them only inside its component (its own html), but not within a parent layout.

Instead of "" you must move its amination inside that component (app-animated-comp).

BrowserAnimationsModule is an package you need to add in your app.module

https://material.angular.io/guide/getting-started

import {BrowserAnimationsModule} from '@angular/platform-browser/animations';

@NgModule({
  ...
  imports: [BrowserAnimationsModule],
  ...
})
export class PizzaPartyAppModule { }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM