如何在Angular 4应用程序中使用Mat-Tree模块

时间:2018-07-24 12:46:35

标签: angular treeview angular-material2

我正在尝试实现树视图Like

Angular版本:4

我从上面的链接中复制了相关代码,并粘贴到我的应用程序组件中,但显示错误:

所以我正在寻找这样的解决方案, 我如何从4升级到5(仅此模块是必要的) 或者如何解决那些编译时错误

  

打字稿错误找不到模块'@ angular / core'

     

Typescript错误找不到模块'rxjs'

Package.Json:

{
  "name": "kalpavriksha-angular-v4",
  "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": {
    "@agm/core": "^1.0.0-beta.1",
    "@agm/snazzy-info-window": "^1.0.0-beta.1",
    "@angular/animations": "^4.4.6",
    "@angular/cdk": "^2.0.0-beta.12",
    "@angular/common": "^4.0.0",
    "@angular/compiler": "^4.0.0",
    "@angular/core": "^4.0.0",
    "@angular/forms": "^4.0.0",
    "@angular/http": "^4.0.0",
    "@angular/material": "^2.0.0-beta.12",
    "@angular/platform-browser": "^4.0.0",
    "@angular/platform-browser-dynamic": "^4.0.0",
    "@angular/router": "^4.0.0",
    "@swimlane/ngx-charts": "^6.1.0",
    "@types/filesaver": "0.0.30",
    "angular-chat": "^1.0.9",
    "angular-datatables": "^4.2.0",
    "angular-file-picker": "^1.2.0",
    "angular-file-saver": "^1.1.3",
    "angular-material": "^1.1.5",
    "angularfire2": "5.0.0-rc.3",
    "angularjs-bootstrap-datetimepicker": "^1.1.4",
    "chart.js": "^2.7.2",
    "chart.piecelabel.js": "^0.11.0",
    "cloudboost": "^2.0.264",
    "core-js": "^2.4.1",
    "d3": "^4.11.0",
    "datatables.net": "^1.10.16",
    "datatables.net-buttons": "^1.4.2",
    "datatables.net-buttons-dt": "^1.4.2",
    "datatables.net-dt": "^1.10.16",
    "datatables.net-select": "^1.2.3",
    "datatables.net-select-dt": "^1.2.3",
    "file-saver": "^1.3.3",
    "firebase": "4.6.0",
    "hammerjs": "^2.0.8",
    "material-design-icons": "^3.0.1",
    "md-date-picker": "^0.1.0",
    "ng-chat": "^1.0.12",
    "ng-snotify": "^4.0.0",
    "ng2-charts": "^1.6.0",
    "ng2-search-filter": "^0.3.1",
    "ng4-loading-spinner": "^1.0.27",
    "ngx-cookie-service": "^1.0.9",
    "ngx-loading": "^1.0.7",
    "ngx-pagination": "^3.1.0",
    "ngx-progress-bar": "0.0.10",
    "rxjs": "^5.4.3",
    "snazzy-info-window": "^1.1.0",
    "time-ago-pipe": "^1.3.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.1",
    "@angular/compiler-cli": "^4.0.0",
    "@angular/language-service": "^4.0.0",
    "@types/datatables.net": "^1.10.6",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/jquery": "^3.2.12",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.0.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.0.4",
    "tslint": "~5.3.2",
    "typescript": "~2.3.3"
  }
}

1 个答案:

答案 0 :(得分:1)

package.json文件中有几处更改更改了

block-body:
  - include: c-block
  - include: pragma
  - include: selector
  - include: literal
  - include: block
  - include: comment

"rxjs": "^5.4.3", 

另外,通过

更新您的角度/核心
"rxjs": "5.5.6" 

如果您想了解更新问题,这里还有更多details