Implementing basic forms with NgForm

The basic denominations of Angular forms are FormControl, FormGroup, and FormArray objects. However, it is often not directly necessary to use these objects at all; Angular provides mechanisms with which you can implicitly create and assign these objects and attach them to the form's DOM elements.

Note

The code, links, and a live example related to this recipe are available at http://ngcookbook.herokuapp.com/5116/.

Getting ready

Suppose you began with the following skeleton application:

[app/article-editor.component.ts] import {Component} from '@angular/core'; @Component({ selector: 'article-editor', template: ` <p><input placeholder="Article title"></p> <p><textarea placeholder="Article text"></textarea></p> <p><button ...

Get Angular 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.