Skip to content

Instantly share code, notes, and snippets.

@realtomaszkula
Last active May 12, 2018 21:04
Show Gist options
  • Save realtomaszkula/2d0f8da428c30a460b582cc11f8a59d6 to your computer and use it in GitHub Desktop.
Save realtomaszkula/2d0f8da428c30a460b582cc11f8a59d6 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
@Component({
selector: 'app-suggested-username',
template: `
<form [formGroup]="form">
<input formControlName="firstName" placeholder="First name" />
<input formControlName="lastName" placeholder="Last name" />
<input formControlName="username" placeholder="Username" />
</form>
`,
styleUrls: ['./suggested-username.component.css']
})
export class SuggestedUsernameComponent implements OnInit {
form: FormGroup;
constructor(private fb: FormBuilder) {}
ngOnInit() {
this.form = this.fb.group({
firstName: '',
lastName: '',
username: ''
});
this.reactiveUsername();
}
reactiveUsername() {
// continue reading to see the implementation
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment