1 import { Component, OnInit } from '@angular/core';
2 import { FormControl, FormGroup, Validators } from '@angular/forms';
3 import { Router } from '@angular/router';
5 import { AuthService } from '../shared';
9 template: require('./login.component.html')
12 export class LoginComponent implements OnInit {
19 private authService: AuthService,
20 private router: Router
24 this.loginForm = new FormGroup({
25 username: new FormControl('', [ <any>Validators.required ]),
26 password: new FormControl('', [ <any>Validators.required ]),
31 this.authService.login(this.username, this.password).subscribe(
35 this.router.navigate(['/videos/list']);
38 console.error(error.json);
40 if (error.json.error === 'invalid_grant') {
41 this.error = 'Credentials are invalid.';
43 this.error = `${error.json.error}: ${error.json.error_description}`;