import { Component , OnInit } from '@angular/core' ; import 'rxjs/add/operator/map' ; import { Router } from '@angular/router' ; import { AuthenticationService } from '../../services/authentication.service' ; @ Component ( { selector : 'app-login' , templateUrl : './login.component.html' , styleUrls : [ './login.component.css' ] } ) export class LoginComponent implements OnInit { public title = 'app works' ; public username = '' ; public password = '' ; public constructor ( private _router , private _authenticationService ) { } public ngOnInit ( ) { this . _authenticationService . logout ( ) ; } public login ( username , password ) { this . _authenticationService . login ( username , password ) . subscribe ( result => { if ( result ) { this . _router . navigate ( [ './things' ] ) ; } } ) ; } }