File tree 4 files changed +42
-2
lines changed
src/components-examples/material/checkbox
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 1
1
import { CommonModule } from '@angular/common' ;
2
2
import { NgModule } from '@angular/core' ;
3
- import { FormsModule } from '@angular/forms' ;
3
+ import { FormsModule , ReactiveFormsModule } from '@angular/forms' ;
4
4
import { MatCardModule } from '@angular/material/card' ;
5
5
import { MatCheckboxModule } from '@angular/material/checkbox' ;
6
6
import { MatRadioModule } from '@angular/material/radio' ;
7
7
import { CheckboxConfigurableExample } from './checkbox-configurable/checkbox-configurable-example' ;
8
- import { CheckboxOverviewExample } from './checkbox-overview/checkbox-overview-example' ;
9
8
import { 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' ;
10
13
11
14
export {
12
15
CheckboxConfigurableExample ,
13
16
CheckboxOverviewExample ,
14
17
CheckboxHarnessExample ,
18
+ CheckboxReactiveFormsExample ,
15
19
} ;
16
20
17
21
const EXAMPLES = [
18
22
CheckboxConfigurableExample ,
19
23
CheckboxOverviewExample ,
20
24
CheckboxHarnessExample ,
25
+ CheckboxReactiveFormsExample ,
21
26
] ;
22
27
23
28
@NgModule ( {
@@ -27,6 +32,7 @@ const EXAMPLES = [
27
32
MatCheckboxModule ,
28
33
MatRadioModule ,
29
34
FormsModule ,
35
+ ReactiveFormsModule ,
30
36
] ,
31
37
declarations : EXAMPLES ,
32
38
exports : EXAMPLES ,
You can’t perform that action at this time.
0 commit comments