【发布时间】:2017-01-04 00:57:37
【问题描述】:
我从 Component 类调用服务并获取 Observable (Customers) Object 作为响应。
如果我使用
<div *ngFor="let cust of customerDetailsItem"> {{cust.id}} </div> 然后我得到了值。但如果我想在组件中使用可观察到的响应,那么它会显示“Undefined”。
constructor(public service:ViewListCustomerServiceService) {
this.service.getCustomerItemList().subscribe(lst =>this.customerDetailsItem=(lst));
console.log(this.customerDetailsItem); //Showing Undefined.
}
因为我想要“customerDetailsItem”将数据分配给组件类中的Json 对象。
【问题讨论】:
标签: angular