Property 'subscribe' does not exist on type '() => Observable'

前端 未结 2 1322
情深已故
情深已故 2020-12-30 02:08

service file

import { Observable } from \'rxjs/Rx\';
import { Http,Response} from \'@angular/http\';
import { Injectable } from \'@angular/core\';
import \'         


        
2条回答
  •  时光取名叫无心
    2020-12-30 02:55

    You are not calling the getVideos method. You are calling subscribe on the function reference of getVideos and not the returned value. Call subscribe after you call getVideos():

    ngOnInit() {
        this.videoserv.getvideos().subscribe((response) => {
             this.videos = response
        });
    }
    

提交回复
热议问题