在Angular 4服务.map功能没有醒

时间:2018-11-03 15:56:33

标签: angular angular7

我是angular 7的初学者。我正在使用angular 7来创建一些应用程序。在使用中,我导入了地图,但是没有用。我该如何解决?这是服务文件的代码。

SharedPreference

这是错误。http.get(...)。map不是函数

2 个答案:

答案 0 :(得分:3)

您需要查看管道,因为您正在使用RxJS最新版本。

return this.http.get('http://jsonplaceholder.typicode.com/users')
    .pipe(
       map(res => res.json())
    );

答案 1 :(得分:1)

android:scrollbarThumbVertical="@color/colorPrimaryDark" 将返回一个Observable。您无法对可观察对象执行this.http.get。您需要map到可观察对象,将结果转换为JSON,然后对其进行.subscribe

示例: .map