Mudanças entre as edições de "Model Driven Forms (Reactive forms) in Angular2"
De Basef
Linha 26: | Linha 26: | ||
'''In your template:''' | '''In your template:''' | ||
+ | <source lang="html"> | ||
<form [formGroup]="myForm"> | <form [formGroup]="myForm"> | ||
<input type="text" formControlName="field1" /> | <input type="text" formControlName="field1" /> | ||
<input type="text" formControlName="field2" /> | <input type="text" formControlName="field2" /> | ||
</form> | </form> | ||
+ | </source> |
Edição das 09h56min de 26 de outubro de 2016
In your Module:
import { ReactiveFormsModule } from '@angular/forms';
Add `ReactiveFormsModule` to `imports` section.
In your Component:
import { FormGroup, FormControl } from '@angular/forms'; export class MyComponent { myForm: FormGroup; constructor() { this.myForm = new FormGroup({ field1: new FormControl(), field2: new FormControl() }); } }
In your template:
Linguagem inválida.
Você precisa especificar uma linguagem, tal como: <source lang="html4strict">...</source>
Linguagens suportadas no realce de sintaxe:
[Expandir]
<form [formGroup]="myForm"> <input type="text" formControlName="field1" /> <input type="text" formControlName="field2" /> </form>