import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { ErrorComponent } from '../error/error.component'; import {MatDialogRef, MatDialog} from '@angular/material'; import { SadeeService } from '../sadee.servise'; @Component({ selector: 'app-login', templateUrl: './login.component.html', styleUrls: ['./login.component.scss'] }) export class LoginComponent implements OnInit { sadeeService : SadeeService; errDialog : MatDialog; router: Router; constructor(router: Router, sadeeService : SadeeService, errDialog : MatDialog) { this.router = router; this.sadeeService = sadeeService; this.errDialog = errDialog; } ngOnInit() { } onSubmit(submittedForm) { this.sadeeService.checkLogin(submittedForm.value.username, submittedForm.value.password, (result) => { if(result) { this.router.navigate(['main']); } else { let errStr = 'Nome de usuário ou senha não existem!'; let errDialogRef = this.errDialog.open(ErrorComponent, { height: '400px', width: '400px' }); errDialogRef.componentInstance.errorMessage = errStr; } }); } }