我有以下image的Json,它是从firebase获得的,现在我只想读取delevery的选项,以便以后比较是否为5来增加计数器1(如果为0则不)增加计数器。
我的设计是要显示像下面的image
那样由愚蠢的人购买的商品数量在我的服务中,我有以下代码:
getShippingPrice(): Observable<Orders> {
const headers = new HttpHeaders({
'Content-Type': 'application/json'
});
const url = 'https://xxxxx-xxxxxx.firebaseio.com/MyOrders/xxxxx.json?auth=xxxxxxxxxxxxxxx&orderBy="shippingPrice"&startAt="5"';
return this.http.get<Orders>( url, { headers } ).pipe(
map( res => {
return res;
}), catchError(this.handleError)
);
}
components.ts
getOrders() {
this._ordersService.getShippingPrice().subscribe(
orders => {
if (orders) {
this.myOrders = orders;
console.log(this.myOrders);
}
},
error => {
console.log(`Error en mostrar las ordenes: ${error}`);
}, () => {
console.log('getData completed');
}
);
}
html
<div class="col-xs-12 col-md-4">
<div class="card">
<div class="card-body card-dash">
<p> Servicio Delevery </p>
<mdb-icon icon="motorcycle"></mdb-icon>
<span>{{myOrders }} Envios</span>
</div>
</div>
</div>
当我尝试使用json管道时,我只是从Firebase集合中获取了密钥
<div class="col-xs-12 col-md-4">
<div class="card">
<div class="card-body card-dash">
<p> Servicio Delevery </p>
<mdb-icon icon="motorcycle"></mdb-icon>
<span>{{myOrders | json }} Envios</span>
</div>
</div>
</div>