2016-12-29 176 views
5

使用cli的角材料2。當我安裝@ angular/material並將其包含在app.module中時,編譯器通過3個警告。角材料2配置錯誤

我就是這樣做

NPM安裝--save @角/材料

.....other imports 

import { MaterialModule } from '@angular/material'; 

@NgModule({ 

    declarations: [ 
    AppComponent 
    ], 

    imports: [ 
    MaterialModule.forRoot(),other imports... 
    ], 

    providers: [], 
    bootstrap: [AppComponent] 
}) 

export class AppModule { } 

其他設置

styles.css的

@import「〜@角/材料/芯/theming/prebuilt/deeppurple-amber.css';

的index.html

... 
    <script src="https://ajax.googleapis.com/ajax/libs/hammerjs/2.0.8/hammer.min.js"></script> 
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> 
... 

警告

1. WARNING in ./~/@angular/material/module.js 
64:4 export 'ProjectionModule' was not foun 
d in './core/index' 
2. WARNING in ./~/@angular/material/module.js 
89:16 export 'ProjectionModule' was not fou 
nd in './core/index' 
3. WARNING in ./~/@angular/material/dialog/ind 
ex.js 
21:75 export 'Platform' was not found in '. 
./core' 

錯誤上運行http://localhost:4200/

Uncaught TypeError: Cannot read property 'prototype' of undefined 
    at __extends (snack-bar-container.js:4) 
    at snack-bar-container.js:28 
    at Object.<anonymous> (snack-bar-container.js:122) 
    at __webpack_require__ (bootstrap 9ff6af8…:52) 
    at Object.<anonymous> (snack-bar-ref.js:70) 
    at __webpack_require__ (bootstrap 9ff6af8…:52) 
    at Object.<anonymous> (menu.js:40) 
    at __webpack_require__ (bootstrap 9ff6af8…:52) 
    at Object.<anonymous> (icon.js:264) 
    at __webpack_require__ (bootstrap 9ff6af8…:52) 

回答

0

從官方documentation,你應該導入每個模塊。我在開發過程中一次性全部導入,但沒有.forRoot(),並且工作正常:

imports: [ 
    MaterialModule, 
    ],