2

我已经达到了Angular 的英雄之旅教程的最新一步。使用 angular-in-memory-web-api 后,我的屏幕上没有出现任何数据。没有编译错误,但是在浏览器的控制台中我得到了这个:

图片说明

一切都与教程中的完全相同。我还没有找到任何解决方案,因此我不得不自己问。

这就是我的 package.json 的外观:

{
  "name": "tour-of-heroes",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "angular-in-memory-web-api": "^0.6.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "~1.7.1",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "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": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }
}
4

1 回答 1

4

这是由于 angular-in-memory-web-api 版本 0.6.0 的变化。解决您的问题的好方法:

npm install angular-in-memory-web-api@0.5.4 --save

如果您下载教程完整示例,则 package.json 具有:

"angular-in-memory-web-api": "~0.5.0",

所以 0.6.0 超出范围。

于 2018-04-03T13:06:21.910 回答