當我調用本地服務器上的GET方法(http://localhost:51085/api/GetMethod)時,我的Web APPI正常工作,它將檢索正確的對象數組。Angular 4 + Web API無法使用GET方法檢索數據
但是,當我把它從Angular4應用程序,返回的可觀測顯示
[object Object] and an error for *ngFor (ERROR Error: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.).
export class AppComponent {
myDesiredDataFromServer$;
constructor(private service: ServiceHTTP) {
this.myDesiredDataFromServer = service.getData();
}
}
任何幫助嗎?
您可以爲Angular 4添加代碼嗎? –
你還可以發佈你的API數據的樣本嗎? – rick
如果你正在返回一個observable,在ngFor中使用異步管道來映射它 – JayDeeEss