Я пытаюсь сравнить два наблюдаемых метода и вернуть результат. Я попробовал пример, но не получил ожидаемый результат. Я надеюсь, что следующий пример (что я пробовал) прояснит вопрос.
GetCountries() : Observable<any>
{
return this.http.GetCountries().subscribe(data => {
return data;
})
}
GetSelectedCities() : Observable<any>
{
return this.http.GetCities().map(data => {
return data
});
}
let cities = [{name:'new york', id:1},
{name:'paris', id:2},
{name:'london', id:3}]
let countries = [{name:'usa', id:1, city:'new york'},
{name:'germany', id:2,city:'berlin'},
{name:'france', id:3,city:'marseille'},
{name:'netherland', id:3,city:'amersterdam'}]
GetNotSelectedCities()
{
this.GetCountries.do(data => {
this.GetSelectedCities.do(response => {
data.filter(x=> return response.filter(d=> d.city !== x.name ) )
})
})
}
Но вместо этого результата я получаю список городов:
[{name:'germany', id:2,city:'berlin'},
{name:'france', id:3,city:'paris'},
{name:'netherland', id:3,city:'amersterdam'}]