0
私はformgroup
を宛先から取得し、このオブジェクトデータをサービスに渡して、それらのルートバスが利用可能かどうかをチェックしますが、別のコンポーネントで。フィルタリングされたデータをあるコンポーネントから別の角度に渡す
home.component.ts
submit(value) {
const data = this.searchForm.value;
this.homeservice.getbus(data).subscribe((res) => {
this.busfilter = res;
console.log(this.busfilter);
this.navigateToBusTicket();
},
() => {
});
}
private navigateToBusTicket() {
this.router.navigate(['busticket']);
}
} home.service.ts
getbus(data) {
return this.http.get('http://127.0.0.1:3000/bus')
.map(
(response: Response) => {
const items = response.json();
for (let i = 0; i < items.length; i++) {
if (data.fromandto.from === items[i].from && data.fromandto.to === items[i].to) {
// console.log(items);
return items;
}
}
})
私はこれを行うためにどのように他のコンポーネントbusticketでデータを返さ購読しますそれ?
あなたは答えは役に立ちましたか? – krzysztofla