import { Component , OnInit } from '@angular/core' ; import { FormBuilder , Validators , FormControl } from '@angular/forms' ; import { Router } from '@angular/router' ; import { uniqueNamesGenerator , adjectives , colors , animals } from 'unique-names-generator' ; @ Component ( { selector : 'app-home' , templateUrl : './home.component.html' , styleUrls : [ './home.component.css' ] } ) export class HomeComponent implements OnInit { public roomForm : FormControl ; public version = require ( '../../../package.json' ) . version ; constructor ( private router , public formBuilder ) { } ngOnInit ( ) { const randomName = uniqueNamesGenerator ( { dictionaries : [ adjectives , colors , animals ] , separator : '-' , } ) ; this . roomForm = new FormControl ( randomName , [ Validators . minLength ( 4 ) , Validators . required ] ) ; } public goToVideoCall ( ) { if ( this . roomForm . valid ) { const roomName = this . roomForm . value . replace ( / /g , '-' ) ; this . roomForm . setValue ( roomName ) ; this . router . navigate ( [ '/' , roomName ] ) ; } } }