Skip to Main Content
Mastering TypeScript 3 - Third Edition
book

Mastering TypeScript 3 - Third Edition

by Nathan Rozentals
February 2019
Beginner content levelBeginner
694 pages
18h 4m
English
Packt Publishing
Content preview from Mastering TypeScript 3 - Third Edition

Using Reactive forms

In order to use Reactive forms in our AppComponent, we will need to set up a new FormGroup property, and include the FormBuilder class as part of our constructor function, as follows:

import { FormBuilder, FormGroup, FormControl } from '@angular/forms'; 
... existing code 
export class AppComponent { 
    .. existing properties  
 
    reactiveFormGroup: FormGroup; 
 
    constructor(private formBuilder: FormBuilder) { 
 
    } 
 
    ... existing code 
} 

Here, we have updated our app.component.ts file with an import of the FormBuilder, FormGroup, and FormControl classes from the Angular framework. We then create a new property on our component class named reactiveFormGroup, which is of type FormGroup. This property will house the internal structure for ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The TypeScript Workshop

The TypeScript Workshop

Ben Grynhaus, Jordan Hudgens, Rayon Hunte, Matt Morgan, Wekoslav Stefanovski

Publisher Resources

ISBN: 9781789536706Supplemental Content