Skip to content

Instantly share code, notes, and snippets.

@ByJC
Last active January 26, 2017 17:08
Show Gist options
  • Save ByJC/220c8fb8d074117ba8c9090682e5ecd0 to your computer and use it in GitHub Desktop.
Save ByJC/220c8fb8d074117ba8c9090682e5ecd0 to your computer and use it in GitHub Desktop.
export class FormControlComponent {
myControl = new FormControl();
results: Observable<any[]>;
constructor(public http: Http) {
this.results = this.myControl.valueChanges
.startWith('someValue')
.map(text => new formatQuery(text)) // generate a url
.switchMap(url => this.http.get(url), (_, res)=> res.json());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment