Angular 4 - 请包括“BrowserAnimationsModule"或“NoopAnimationsModule"在您的申请中 [英] Angular 4 - Please include either "BrowserAnimationsModule" or "NoopAnimationsModule" in your application

查看:22
本文介绍了Angular 4 - 请包括“BrowserAnimationsModule"或“NoopAnimationsModule"在您的申请中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在浏览器上启动 Angular 应用程序时遇到问题.一切正常,代码说话,但我仍然收到此错误:

<块引用>

找到合成属性@routerAnimations.请包括BrowserAnimationsModuleNoopAnimationsModule 在你的申请.

我已经查看了关于这个主题的帖子,有很多帖子,但他们的回答都是一样的:

import { BrowserAnimationsModule } from '@angular/platform-b​​rowser/animations';

并将其包含在应用模块的导入中.

导入:[浏览器动画模块,...]

这就是我所做的,但仍然出现相同的错误.我一直在寻找这个解决方案的时间.任何人都知道什么可以解决它?谢谢

这是我的 package.json:

<代码>{名称":angular-bc",版本":0.0.0",许可证":MIT",脚本":{ng":ng",开始":服务",build":ng build",测试":ng测试",lint":ng lint",e2e":ng e2e"},私人":真的,依赖关系":{@angular/animations":^4.2.4",@angular/common":^4.2.4",@angular/compiler":^4.2.4",@angular/core":^4.2.4",@angular/forms":^4.2.4",@angular/http":^4.2.4",@angular/platform-b​​rowser":^4.2.4",@angular/platform-b​​rowser-dynamic":^4.2.4",@angular/router":^4.2.4",core-js":^2.4.1",rxjs":^5.4.2",zone.js":^0.8.14"},开发依赖":{@angular/cli":1.4.3",@angular/compiler-cli":^4.2.4",@angular/language-service":^4.2.4",@types/jasmine":~2.5.53",@types/jasminewd2":~2.0.2",@types/node":~6.0.60",codelyzer":~3.1.1",茉莉花芯":~2.6.2",jasmine-spec-reporter":~4.1.0",业力":~1.7.0",karma-chrome-launcher":~2.1.1",karma-cli":~1.0.1",karma-coverage-istanbul-reporter":^1.2.1",业力茉莉":~1.1.0",karma-jasmine-html-reporter":^0.2.2",量角器":~5.1.2",ts-node":~3.2.0",tslint":~5.3.2",打字稿":~2.3.3"}}

组件:从答案中复制

<router-outlet #myOutlet></router-outlet>

解决方案

我解决了这个问题,问题是我的 app.component.html 中的@routerAnimations":

<router-outlet #myOutlet></router-outlet>

当我删除它时,一切正常

I'm having a problem when I launch my Angular app on my browser. Everything works code speaking but I'm still getting this error:

Found the synthetic property @routerAnimations. Please include either BrowserAnimationsModule or NoopAnimationsModule in your application.

I already checked the posts on this subject and there's quite a lot but all of them answered the same:

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

and include it in the app module's imports.

imports: [
    BrowserAnimationsModule,
    ... 
]

That's what I did but still got the same error. I've been looking for hours for this solution. Anyone knows what could fix it ? Thanks

Here's my package.json:

{
  "name": "angular-bc",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.2.4",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "core-js": "^2.4.1",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.3",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.1.1",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

Components : copied from answer

<div [@routerAnimations]="myOutlet.state">
    <router-outlet #myOutlet></router-outlet>
</div>

解决方案

I solved the issue, the problem was the "@routerAnimations" in my app.component.html:

<div [@routerAnimations]="myOutlet.state">
    <router-outlet #myOutlet></router-outlet>
</div>

When I removed it, everything worked just fine

这篇关于Angular 4 - 请包括“BrowserAnimationsModule"或“NoopAnimationsModule"在您的申请中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆