File tree Expand file tree Collapse file tree 4 files changed +42
-2
lines changed
src/components-examples/material/checkbox Expand file tree Collapse file tree 4 files changed +42
-2
lines changed Original file line number Diff line number Diff line change 1+ .example-section {
2+ margin : 12px 0 ;
3+ }
Original file line number Diff line number Diff line change 1+ < section class ="example-section " [formGroup] ="toppings ">
2+ < h4 > Select your toppings:</ h4 >
3+ < p > < mat-checkbox formControlName ="pepperoni "> Pepperoni</ mat-checkbox > </ p >
4+ < p > < mat-checkbox formControlName ="extracheese "> Extra Cheese</ mat-checkbox > </ p >
5+ < p > < mat-checkbox formControlName ="mushroom "> Mushroom</ mat-checkbox > </ p >
6+ </ section >
7+
8+ < section class ="example-section " [formGroup] ="toppings ">
9+ < h4 > You chose:</ h4 >
10+ {{toppings.value | json}}
11+ </ section >
Original file line number Diff line number Diff line change 1+ import { Component } from '@angular/core' ;
2+ import { FormBuilder , FormGroup } from '@angular/forms' ;
3+
4+ /** @title Checkboxes with reactive forms */
5+ @Component ( {
6+ selector : 'checkbox-reactive-forms-example' ,
7+ templateUrl : 'checkbox-reactive-forms-example.html' ,
8+ styleUrls : [ 'checkbox-reactive-forms-example.css' ]
9+ } )
10+ export class CheckboxReactiveFormsExample {
11+ toppings : FormGroup ;
12+
13+ constructor ( fb : FormBuilder ) {
14+ this . toppings = fb . group ( {
15+ pepperoni : false ,
16+ extracheese : false ,
17+ mushroom : false
18+ } ) ;
19+ }
20+ }
Original file line number Diff line number Diff line change 11import { CommonModule } from '@angular/common' ;
22import { NgModule } from '@angular/core' ;
3- import { FormsModule } from '@angular/forms' ;
3+ import { FormsModule , ReactiveFormsModule } from '@angular/forms' ;
44import { MatCardModule } from '@angular/material/card' ;
55import { MatCheckboxModule } from '@angular/material/checkbox' ;
66import { MatRadioModule } from '@angular/material/radio' ;
77import { CheckboxConfigurableExample } from './checkbox-configurable/checkbox-configurable-example' ;
8- import { CheckboxOverviewExample } from './checkbox-overview/checkbox-overview-example' ;
98import { CheckboxHarnessExample } from './checkbox-harness/checkbox-harness-example' ;
9+ import { CheckboxOverviewExample } from './checkbox-overview/checkbox-overview-example' ;
10+ import {
11+ CheckboxReactiveFormsExample
12+ } from './checkbox-reactive-forms/checkbox-reactive-forms-example' ;
1013
1114export {
1215 CheckboxConfigurableExample ,
1316 CheckboxOverviewExample ,
1417 CheckboxHarnessExample ,
18+ CheckboxReactiveFormsExample ,
1519} ;
1620
1721const EXAMPLES = [
1822 CheckboxConfigurableExample ,
1923 CheckboxOverviewExample ,
2024 CheckboxHarnessExample ,
25+ CheckboxReactiveFormsExample ,
2126] ;
2227
2328@NgModule ( {
@@ -27,6 +32,7 @@ const EXAMPLES = [
2732 MatCheckboxModule ,
2833 MatRadioModule ,
2934 FormsModule ,
35+ ReactiveFormsModule ,
3036 ] ,
3137 declarations : EXAMPLES ,
3238 exports : EXAMPLES ,
You can’t perform that action at this time.
0 commit comments