import { Component , OnInit } from '@angular/core' ; import { Router } from '@angular/router' ; import { MatDialog } from '@angular/material' ; import { AuthService } from '../core/auth.service' ; import { TokenStorage } from '../core/token.storage' ; @ Component ( { selector : 'app-login' , templateUrl : './login.component.html' , styleUrls : [ './login.component.css' ] } ) export class LoginComponent { constructor ( private router , public dialog , private authService , private token ) { } username : string ; password : string ; login ( ) { this . authService . attemptAuth ( this . username , this . password ) . subscribe ( data => { this . token . saveToken ( data . token ) ; this . router . navigate ( [ 'user' ] ) ; } ) ; } }