TypeError: Object(…) is not a function for angular-material

后端 未结 2 972
北海茫月
北海茫月 2021-01-19 23:49

In angular 7, trying to use angular material mat-dialog-content. While importing in app.module.ts it gives the following error:

TypeError

相关标签:
2条回答
  • 2021-01-19 23:51
        "@angular/animations": "^7.2.15",
        "@angular/cdk": "^8.0.1",
        "@angular/common": "~7.2.0",
        "@angular/compiler": "~7.2.0",
        "@angular/core": "~7.2.0",
        "@angular/forms": "~7.2.0",
        "@angular/material": "^8.0.1",
        "@angular/platform-browser": "~7.2.0",
        "@angular/platform-browser-dynamic": "~7.2.0",
    

    You use @angular/cdk and @angular/material in version 8 together with @angular/core @angular/common 7. If you want to stay at Angular 7 uninstall cdk and material and install the specific cdk and material for version 7.

    npm uninstall @angular/cdk @angular/material
    
    ... find out the version 7
    
    npm show @angular/cdk versions
    npm show @angular/material versions
    
    ... and then install the specific one
    
    npm install @angular/cdk@7.2.15
    

    Or just upgrade your angular

    npm install -g @angular/cli@latest
    ng update @angular/cli @angular-devkit/build-angular
    ng update @angular/core @angular/cdk @angular/material
    

    After one of this two options try it again.

    0 讨论(0)
  • 2021-01-20 00:09

    Change the dependencies to the lowest version of @angular/core or @angular/cdk. It's normally due to a mismatch

    "dependencies": {
      "@angular/core": "^7.2.0",
      "@angular/cdk": "^7.2.0",
      "@angular/material": "^7.2.0"    
    },
    
    0 讨论(0)
提交回复
热议问题