Angular 5+ cannot save result form observable response

前端 未结 4 1659
刺人心
刺人心 2021-01-25 00:58

I have an Angular app which consumes data from a webapi. When i make a request then i get an typed observable.

now when i do this:

data: Product[];
produ         


        
4条回答
  •  醉话见心
    2021-01-25 01:51

    You should save the data in the HTTP Observable subscription:

    productService.getByProductId("061000957").subscribe(res => {
       this.data = res;
       console.log(this.data)   //you can see
    })
    

提交回复
热议问题