3

使用 Angular Material 2.0.0-alpha.8-1 升级我的 Angular 2.0.0-rc.6 应用程序,我现在得到如下编译错误:

Property 'forRoot' does not exist on type 'typeof MdCoreModule'.

这是AppModule

import { MdCoreModule } from '@angular2-material/core/core';
import { MdButtonModule } from '@angular2-material/button/button';
import { MdButtonToggleModule } from '@angular2-material/button-toggle/button-toggle';
import { MdCardModule } from '@angular2-material/card/card';
import { MdCheckboxModule } from '@angular2-material/checkbox/checkbox';
// ... additional imports

@NgModule({
  declarations: [
    AppComponent,
    // ... additional application-specific declarations
  ],
  imports: [
    BrowserModule,
    CommonModule,
    ReactiveFormsModule,
    HttpModule,
    JsonpModule,
    MdCoreModule.forRoot(),
    MdButtonModule.forRoot(),
    MdButtonToggleModule.forRoot(),
    MdCardModule.forRoot(),
    MdCheckboxModule.forRoot(),
    // ... additional imports
  ],
  providers : [
    Configuration,
    // ... additional application-specific providers
  ],
  entryComponents: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {    
}

这是CHANGELOG中推荐的。任何想法我做错了什么?

  "dependencies": {
    "@angular/common": "2.0.0-rc.6",
    "@angular/compiler": "2.0.0-rc.6",
    "@angular/core": "2.0.0-rc.6",
    "@angular/forms": "2.0.0-rc.6",
    "@angular/http": "2.0.0-rc.6",
    "@angular/platform-browser": "2.0.0-rc.6",
    "@angular/platform-browser-dynamic": "2.0.0-rc.6",
    "@angular/router": "3.0.0-rc.2",
    "@angular2-material/button": "2.0.0-alpha.8-1",
    "@angular2-material/button-toggle": "2.0.0-alpha.8-1",
    "@angular2-material/card": "2.0.0-alpha.8-1",
    "@angular2-material/checkbox": "2.0.0-alpha.8-1",
    "@angular2-material/core": "2.0.0-alpha.8-1",
    "@angular2-material/grid-list": "2.0.0-alpha.8-1",
    "@angular2-material/icon": "2.0.0-alpha.8-1",
    "@angular2-material/input": "2.0.0-alpha.8-1",
    "@angular2-material/list": "2.0.0-alpha.8-1",
    "@angular2-material/menu": "2.0.0-alpha.8-1",
    "@angular2-material/progress-bar": "2.0.0-alpha.8-1",
    "@angular2-material/progress-circle": "2.0.0-alpha.8-1",
    "@angular2-material/radio": "2.0.0-alpha.8-1",
    "@angular2-material/sidenav": "2.0.0-alpha.8-1",
    "@angular2-material/slide-toggle": "2.0.0-alpha.8-1",
    "@angular2-material/slider": "2.0.0-alpha.8-1",
    "@angular2-material/tabs": "2.0.0-alpha.8-1",
    "@angular2-material/toolbar": "2.0.0-alpha.8-1",
    "@angular2-material/tooltip": "2.0.0-alpha.8-1",
    "core-js": "^2.4.0",
    "reflect-metadata": "0.1.8",
    "rxjs": "5.0.0-beta.11",
    "ts-helpers": "^1.1.1",
    "zone.js": "0.6.17"
  }

  "devDependencies": {
    "@types/hammerjs": "2.0.32",
    "@types/jasmine": "^2.2.30",
    "angular-cli": "1.0.0-beta.11-webpack.8",
    "codelyzer": "0.0.26",
    "hammerjs": "2.0.8",
    "jasmine-core": "2.4.1",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "0.13.22",
    "karma-chrome-launcher": "0.2.3",
    "karma-jasmine": "0.3.8",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "4.0.3",
    "reflect-metadata": "0.1.8",
    "string-replace-loader": "1.0.3",
    "ts-node": "1.2.1",
    "tslint": "3.13.0",
    "typescript": "2.0.0"
  }

环境:

angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: linux x64
4

2 回答 2

2

使用 Angular2.0.0和 Angular Material 2.0.0-alpha.8-2,导入现在按文档说明工作:

import { MdButtonModule } from '@angular2-material/button';
//...
MdButtonModule.forRoot(),

注意从button/button到 just的变化button

于 2016-09-20T21:29:26.037 回答
1

虽然文档说要使用forRoot(),但它适用于2.0.0-alpha.8 ectoplasm-helicopter (2016-09-01)

我不确定是否要在您重新导出它们时使用它,我尝试过没有forRoot()并且工作正常。

看到这个Plunker!

希望这可以帮助!!

于 2016-09-07T17:39:29.207 回答