I am making a mapquest api application. I have 2 input boxes, one for "from" and one for "to" for the navigation. With those values hardcoded in my app.component, it returns the json correctly. however, I have nooooo idea how to get those 2 distinct search boxes into my pipe using the method that I'm using. here are my input boxes in the html:
<form >
<input #from id="from"
(keyup)="search(from.value)"/>
<input #to id="to"
(keyup)="search2(to.value)"/>
</form>
and here is my typescript:
export class AppComponent implements OnInit {
title = 'hw5-part1';
mapResult: any;
to: string = 'boston';
from: string = 'poughkeepsie';
private searchTerms: Subject<string>;
any help would be super appreciable.
constructor(private mapQuestService: MapQuestService) { }
search(term: string): void {
this.searchTerms.next(term); }
ngOnInit() {
this.searchTerms = new Subject<string>();
this.searchTerms.pipe(
debounceTime(1000),
distinctUntilChanged(),
switchMap((x) => {
console.log('the term is ', x)
console.log(this.from, this.to);
return this.mapQuestService.getMap(this.from, this.to);
}))
.subscribe((result: any) => {
console.log(result);
this.mapResult = result.items;
console.log(result.route.legs[0].maneuvers);
});
}
}