Angular HTTP GET with TypeScript error http.get(…).map is not a function in [null]

前端 未结 19 2456
时光取名叫无心
时光取名叫无心 2020-11-22 03:36

I have a problem with HTTP in Angular.

I just want to GET a JSON list and show it in the view.

Service class

im         


        
19条回答
  •  广开言路
    2020-11-22 04:27

    Since Http service in angular2 returns an Observable type, From your Angular2 installation directory('node_modules' in my case),We need to import map function of the Observable in your component using http service,as:

    import 'rxjs/add/operator/map';
    

提交回复
热议问题