I have data like the one below in my mongoDB and I retrieve calling the service and later subscribing to it. But I want to filter the before subcribing to it in a way that i just subscribe to the filtered data base on my condition. I want to filtered verifying that one of the camps in the data from the backend matches the "this.idcalbuscador". (See the .filter()). I haven't been able to achieve this, could anyone help? Just new to observables
Data
{
"_id" : ObjectId("588850b746f8ce140c1fe8cf"),
"idpertenalcalendario" : ObjectId("5885bfe452c6ba1d50f37f19"),
"enabled" : true,
"forma" : "Rombo",
"color" : "Red",
"type" : "point",
"descrip" : "ghghghgh",
"startDate" : "2017-01-15",
"nameHito" : "gjgjgjgg",
}
Code
//retrieve the datas
this._hitoService.getHitos()
.filter(resp => resp.idpertenalcalendario === this.idcalbuscador )
.subscribe(hito1 =>{
if (typeof this.nom_cal1 === "undefined"){
swal("Atencion!", "Busca un calendario con el buscador del Side Menu")
}else {
drawtimeline1_1(this.hito1, this.nom_cal1);
}
});