Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save realtomaszkula/8b87acda58c3bcdfc7b3d59533b4cdb5 to your computer and use it in GitHub Desktop.
Save realtomaszkula/8b87acda58c3bcdfc7b3d59533b4cdb5 to your computer and use it in GitHub Desktop.
reactiveUsername() {
const firstName = this.form.get('firstName');
const lastName = this.form.get('lastName');
const username = this.form.get('username');
const combined$ = combineLatest(
firstName.valueChanges,
lastName.valueChanges
)
.pipe(map(([first, last]) => (first && last ? `${first}-${last}` : '')))
.subscribe(value => username.setValue(value));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment