import { Component } from '@angular/core' ; import { FormBuilder , FormGroup , Validators } from '@angular/forms' ; title @ Component ( { selector : 'slide-toggle-forms-example' , templateUrl : './slide-toggle-forms-example.html' , styleUrls : [ './slide-toggle-forms-example.css' ] , } ) export class SlideToggleFormsExample { isChecked = true ; formGroup : FormGroup ; constructor ( formBuilder ) { this . formGroup = formBuilder . group ( { enableWifi : '' , acceptTerms : [ '' , Validators . requiredTrue ] } ) ; } onFormSubmit ( ) { alert ( JSON . stringify ( this . formGroup . value , null , 2 ) ) ; } }