import { Component , OnInit , ViewEncapsulation } from '@angular/core' ; import { Router } from '@angular/router' ; import { Token } from 'src/app/storage/Token' ; import { ConnectionService } from 'src/app/services/connection.service' ; import { DashboardRouter } from 'src/app/router/DashboardRouter' ; @ Component ( { selector : 'app-login' , templateUrl : './login.component.html' , styleUrls : [ './login.component.scss' ] , encapsulation : ViewEncapsulation . None , } ) export class LoginComponent implements OnInit { public username : string ; public password : string ; public hide = true ; constructor ( private connectionService , private router ) { } ngOnInit ( ) { return ; } submit ( ) { this . connectionService . login ( { username : this . username , password : this . password } ) . then ( ( { token } ) => { if ( token ) { new Token ( ) . set ( token ) ; this . router . navigateByUrl ( DashboardRouter . redirectToList ( ) ) ; } } ) ; } }