2017-10-11 55 views
2

我在瀏覽器中啓動我的Angular應用程序時出現問題。一切正常的代碼來說,但我仍然收到此錯誤:Angular 4 - 請在您的應用程序中包含「BrowserAnimationsModule」或「NoopAnimationsModule」

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

我已經檢查了這個問題的帖子,並有相當多,但所有的人都回答一樣:

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

,包括它在應用程序模塊的導入中。

imports: [ 
    BrowserAnimationsModule, 
    ... 
] 

這就是我所做的,但仍然有同樣的錯誤。我一直在尋找這個解決方案的小時。任何人都知道什麼可以解決它?由於

這裏是我的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" 
    } 
} 
+0

您還需要添加'BrowserModule'你有沒有 –

+0

是的,當你用angular-cli生成項目時它已經存在了 – Messerschmitt

+0

檢查你是否有nimations安裝在你的package.json –

回答

0

我解決了問題,這個問題在我的app.component.html的 「@routerAnimations」:

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

當我刪除它,一切工作正常

相關問題