import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; import { MenuService } from '../service/menu.service'; @Component({ selector: 'app-auth', templateUrl: './auth.component.html', styleUrls: ['./auth.component.scss'] }) export class AuthComponent implements OnInit { public userForm: FormGroup = new FormGroup({ password: new FormControl('abcdefg', [Validators.minLength(3), Validators.maxLength(20)]), email: new FormControl('email@email.com', Validators.email) }); constructor(private menuService: MenuService, private rounter: Router) { } ngOnInit(): void { this.menuService.loginSuccess.emit(null); } submitForm() { console.log(this.userForm); this.menuService.loginSuccess.emit(this.userForm) this.rounter.navigate(["/dashboard"]); } }