Angular 从Web服务器填充ngFor表时出错
我尝试从web服务器获取数据,并用Angular 从Web服务器填充ngFor表时出错,angular,typescript,fetch,ngfor,Angular,Typescript,Fetch,Ngfor,我尝试从web服务器获取数据,并用ngFor填充一个表 这是我使用ngFor的表格: <div class="applic-liste"> <table class="table table-striped table-hover table-bordered"> <tbody> <tr *ngFor="let application of applications"> <td>{{applica
ngFor
填充一个表
这是我使用ngFor
的表格:
<div class="applic-liste">
<table class="table table-striped table-hover table-bordered">
<tbody>
<tr *ngFor="let application of applications">
<td>{{application.id}}</td>
<td>{{application.name}}</td>
<td>{{application.version}}</td>
<td>{{application.fromTo}}</td>
<td>{{application.description}}</td>
<td>{{application.geography}}</td>
</tr>
</tbody>
</table>
</div>
这是我的服务
,我在这里连接到web服务器:
@Injectable()
export class DbService {
applications=[];
private _serverUrl: string = "http://localhost/api/";
constructor(private _http:Http) { }
getData(){
return this._http.get(this._serverUrl+'select.php').
map((response:Response) => response.json);
}
}
我还在这个类中定义了我的应用程序数组
:
export class Application implements OnInit {
constructor() { }
name: string;
version: string;
fromTo: string;
description: string;
geography: string;
ngOnInit() {
}
}
以下是我得到的错误:
有人能帮我吗。我是个新手。。我不知道问题出在哪里
我感谢你的回答
编辑:
这是我的json响应:
[{“id”:“1”,“name”:“TestName”,“version”:“1.2”,“fromTo”:“Test”,“description”:“Beschreibung”,“geography”:“geography”}]
因为错误表明应用程序是可观察的,而不是可到达的
*ngFor="let application of applications | async"
你的反应如何?应用程序您是指我从web服务器获取的json数据吗?查看我的编辑我以前尝试过这个,但是我得到了额外的错误:
Error:InvalidPipeArgument:'function()
…从map((response:response)=>response.json)更改此行;映射((response:response)=>response.json());
*ngFor="let application of applications | async"