Skip to content

Instantly share code, notes, and snippets.

@nirlanka
Last active August 14, 2018 18:12
Show Gist options
  • Save nirlanka/9a0e67fa05e6d65599f00c8581a54ade to your computer and use it in GitHub Desktop.
Save nirlanka/9a0e67fa05e6d65599f00c8581a54ade to your computer and use it in GitHub Desktop.
import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
// Component code:
addFriendForm: FormGroup;
private _user = {
name: 'Amarabandu Rupasingha',
email: '[email protected]',
};
userFormItems = {
name: new FormControl(this._user.name, [Validators.required]),
email: new FormControl(this._user.email, [Validators.required])
};
constructor(formBuilder: FormBuilder) {
this.addFriendForm = formBuilder.group(this.userFormItems);
}
send = () => console.log(this.addFriendForm.value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment