我用Angular -seed升级了一个Angular 4项目,现在得到了这个错误
找到合成属性@panelState。请在应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。
我该如何解决这个问题?错误消息到底告诉我什么?
我用Angular -seed升级了一个Angular 4项目,现在得到了这个错误
找到合成属性@panelState。请在应用程序中包含“BrowserAnimationsModule”或“NoopAnimationsModule”。
我该如何解决这个问题?错误消息到底告诉我什么?
当前回答
对我来说是因为我把动画名放在方括号里。
<div [@animation]></div>
但在我拆除支架后,一切都正常工作:
<div @animation></div>
其他回答
我要做的就是安装这个
npm install @angular/animations@latest --save
然后导入
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
到你的app.module.ts文件。
试试这个
NPM install @angular/animations@latest
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
这对我很有用。
我得到以下错误:
Found the synthetic property @collapse. Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application.
我遵循Ploppy接受的答案,它解决了我的问题。
以下是步骤:
1.
import { trigger, state, style, transition, animate } from '@angular/animations';
Or
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
2. Define the same in the import array in the root module.
它将解决错误。编码快乐! !
对我来说是因为我把动画名放在方括号里。
<div [@animation]></div>
但在我拆除支架后,一切都正常工作:
<div @animation></div>
此错误消息通常具有误导性。
你可能忘记了导入BrowserAnimationsModule。但那不是我的问题。我在根AppModule中导入BrowserAnimationsModule,就像每个人都应该做的那样。
问题与模块完全无关。我在组件模板中动画一个*ngIf,但我忘记在@Component中提到它。组件类的动画。
@Component({
selector: '...',
templateUrl: './...',
animations: [myNgIfAnimation] // <-- Don't forget!
})
如果你在模板中使用一个动画,你也必须在组件的动画元数据中列出该动画…每一次。