import { Component } from "@angular/core"; import { FormBuilder, FormGroup, Validators } from "@angular/common"; @Component({ selector: "my-form", template: `` }) export class MyFormComponent { myForm: FormGroup; constructor(fb: FormBuilder) { this.myForm = fb.group({ name: ["", Validators.required] }); } onSubmit() { console.log(this.myForm.value); // { name: "John" } } } In this example, we create a simple form with a single field for the user's name. We then use the FormBuilder to create a new ControlGroup instance and attach it to the form. We also add a validator to the name field to ensure it is not empty. When the form is submitted, the onSubmit method is called and we can access the form's values using the `this.myForm.value` property. The ControlGroup class is part of the @angular/common package library.