Skip to content

Instantly share code, notes, and snippets.

@uno-de-piera
Created January 7, 2018 15:31
Show Gist options
  • Save uno-de-piera/82cfeca249ce3606b2fc481356ee3b06 to your computer and use it in GitHub Desktop.
Save uno-de-piera/82cfeca249ce3606b2fc481356ee3b06 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import {Title} from '@angular/platform-browser';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
loginForm: FormGroup;
constructor(
private fb: FormBuilder,
title: Title
) {
title.setTitle('Login Angular 5');
this.buildForm();
}
buildForm() {
this.loginForm = this.fb.group({
email: ['', Validators.compose([Validators.required, Validators.email]) ],
password: ['', Validators.compose([Validators.required, Validators.minLength(6)]) ],
});
}
ngOnInit() {
}
submit() {
const email = this.loginForm.get('email').value;
const password = this.loginForm.get('password').value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment