angular官网教程第7个HTTP,找不到angular-in-memory-web-api

我在学习angula中文网第七个教程http时,有一个api接口找不到,遍寻staroverflow跟google无果...

package.json

{
  "name": "test1",
  "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": {
    "@angular/common": "^2.4.0",
    "@angular/compiler": "^2.4.0",
    "@angular/core": "^2.4.0",
    "@angular/forms": "^2.4.0",
    "@angular/http": "^2.4.0",
    "@angular/platform-browser": "^2.4.0",
    "@angular/platform-browser-dynamic": "^2.4.0",
    "@angular/router": "^3.4.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.7.6"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0-rc.2",
    "@angular/compiler-cli": "^2.4.0",
    "@types/jasmine": "2.5.38",
    "@types/node": "~6.0.60",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-coverage-istanbul-reporter": "^0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.0.0"
  }
}

这是报错的画面
图片描述

操作台报错画面
图片描述

阅读 10k
6 个回答
npm i --save angular2-in-memory-web-api

自问自答

npm i angular-in-memory-web-api

缺少了这个就安装这个,参考链接

英文版文档中有:npm install angular-in-memory-web-api --save
Docs地址:https://next.angular.io/tutor...
而且中文版文档最后一篇写出来的有问题,在线演示也是,会有以下错误信息

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'slice' of undefined
TypeError: Cannot read property 'slice' of undefined

而英文版的演示可以运行,应该是中文版文档并未及时维护
英文版第七章在线案例:https://embed.plnkr.co/?show=...

我也是遇到了同样的问题,上面说的我都测试了
我是两个都下载完成了之后,就好了
图片描述

图片描述

新手上路,请多包涵
新手上路,请多包涵

上面的没有一个能解决的,,最后把angular-in-memory-web-api和angular2-in-memory-web-api全部删掉。使用cnpm install angular-in-memory-web-api --save 安装成功。之后没有再报错。后面的人可以试试

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏