Skip to content

Instantly share code, notes, and snippets.

@matthieu-D
Created February 9, 2017 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthieu-D/ac9416b7bdd7bbc8e0183273c5711846 to your computer and use it in GitHub Desktop.
Save matthieu-D/ac9416b7bdd7bbc8e0183273c5711846 to your computer and use it in GitHub Desktop.
import { Component } from '@angular/core';
import { FormGroup, FormBuilder } from '@angular/forms';
@Component({
selector: 'my-home',
templateUrl: './home.component.html'
})
export class HomeComponent {
userForm: FormGroup;
constructor (formBuilder: FormBuilder) {
this.userForm = formBuilder.group({
name: '',
email: '',
address: formBuilder.group({
country: '',
city: '',
})
});
}
onFormSubmitted(form) {
console.log('form value:', form.value);
// Rest of the logic here
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment