Last active
March 8, 2017 20:25
-
-
Save matthieu-D/4783445770ee6c60282e68237b6c3539 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class HomeComponent { | |
userForm: FormGroup; | |
constructor (formBuilder: FormBuilder) { | |
this.userForm = formBuilder.group({ | |
name: ['', this.validateName ], | |
email: '', | |
address: formBuilder.group({ | |
country: '', | |
city: '', | |
}) | |
}); | |
} | |
validateName(form) { | |
return form.value.trim() !== '' ? null : { | |
validateName : { | |
errors: true | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment