Skip to content

Instantly share code, notes, and snippets.

@johnlindquist
Created December 10, 2015 12:50
Show Gist options
  • Save johnlindquist/3fe18725fc67e2177b27 to your computer and use it in GitHub Desktop.
Save johnlindquist/3fe18725fc67e2177b27 to your computer and use it in GitHub Desktop.
import {Component} from 'angular2/core';
import {Control} from 'angular2/common';
import {Http} from 'angular2/http'
import {Subject} from "rxjs";
@Component({
selector: 'app',
template: `
<input type="number" [ngFormControl]="numControl" />
{{(contact | async)?.name?.first}}
{{(contact | async)?.name?.last}}
`
})
export class App {
numControl = new Control();
contact = new Subject();
constructor(http:Http){
this.numControl
.valueChanges
.switchMap(id => http.get('http://localhost:3000/people/' + id)
.map(res => res.json()))
.subscribe(this.contact);
this.numControl.updateValue(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment