Map doesn't exist on Observable<Object> with angular 6.0.0 and rxjs 6.1.0

前端 未结 7 738
情歌与酒
情歌与酒 2020-12-29 07:46

Hi I\'m trying to follow a tutorial on angular but the tutorial was made in September. I believe the person used angular-cli 1.3.2. I\'m not sure which version of rxjs he wa

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 08:08

    i was facing the same problem. lets change the way to import map. use the code which i have written below

    import { map } from "rxjs/operators";

    then use pipe with map. see the example for better understanding

    import {Http,Headers,Response} from '@angular/http';
    import { map } from "rxjs/operators";
    
    
    @Injectable({
      providedIn: 'root'
    })
    export class ContactServiceService {
    
      constructor(private http:Http) { }
    
      getContactList(){
        return this.http.get('http://localhost:3000/contact')
        .pipe(map(res => res.json()));
      }
    
    }
    
    

提交回复
热议问题