Node.js MEAN SATCK angular2:从typescript中的多个api获取数据 与angular2、nodejs、expressjs、mongodb合作。 我希望所有的api返回数据并显示在html页面上。
这是我的.ts文件代码。 所有经过测试的API都可以从mongodb返回数据。 但是第一个api返回数据并显示在html页面上。 在这种情况下,countphones api retuns数据和其他两个不可用。 但是当第一个被注释时,第二个开始通过html显示数据 页 这种情况就像先到先得的节目。Node.js MEAN SATCK angular2:从typescript中的多个api获取数据 与angular2、nodejs、expressjs、mongodb合作。 我希望所有的api返回数据并显示在html页面上。,node.js,angular,typescript,mean-stack,Node.js,Angular,Typescript,Mean Stack,这是我的.ts文件代码。 所有经过测试的API都可以从mongodb返回数据。 但是第一个api返回数据并显示在html页面上。 在这种情况下,countphones api retuns数据和其他两个不可用。 但是当第一个被注释时,第二个开始通过html显示数据 页 这种情况就像先到先得的节目。 return表示这是代码最不可能运行的内容。它将忽略返回块之后的内容。然后如何处理。 export class AppComponent { phone$ = http.get("...").m
return表示这是代码最不可能运行的内容。它将忽略返回块之后的内容。然后如何处理。
export class AppComponent {
phone$ = http.get("...").map(r => r.json())
laptop$ = http.get("...").map(r => r.json())
television$ = http.get("...").map(r => r.json())
ngOnInit(){
Observable
.forkJoin(this.phone$, this.laptop$, this.television$)
.subscribe(([phones, laptops, televisions])=>{
this.phones = phones;
this.laptios = laptops;
this.televisions = televisions;
});
}
}