|
1 | 1 | <h2>Linear Vertical Stepper Demo</h2> |
2 | | -<form [formGroup]="formGroup" novalidate> |
3 | | - <div formArrayName="formArray"> |
4 | | - <md-vertical-stepper> |
5 | | - <md-step> |
6 | | - <div [formGroupName]="0"> |
7 | | - <ng-template mdStepLabel>Fill out your name</ng-template> |
8 | | - <md-input-container> |
9 | | - <input mdInput placeholder="First Name" formControlName="firstNameFormCtrl" required> |
10 | | - <md-error>This field is required</md-error> |
11 | | - </md-input-container> |
| 2 | +<form [formGroup]="formGroup"> |
| 3 | + <md-vertical-stepper formArrayName="formArray"> |
| 4 | + <md-step formGroupName="0"> |
| 5 | + <ng-template mdStepLabel>Fill out your name</ng-template> |
| 6 | + <md-input-container> |
| 7 | + <input mdInput placeholder="First Name" formControlName="firstNameFormCtrl" required> |
| 8 | + <md-error>This field is required</md-error> |
| 9 | + </md-input-container> |
12 | 10 |
|
13 | | - <md-input-container> |
14 | | - <input mdInput placeholder="Last Name" formControlName="lastNameFormCtrl" required> |
15 | | - <md-error>This field is required</md-error> |
16 | | - </md-input-container> |
17 | | - <div> |
18 | | - <button md-button mdStepperNext>Next</button> |
19 | | - </div> |
20 | | - </div> |
21 | | - </md-step> |
| 11 | + <md-input-container> |
| 12 | + <input mdInput placeholder="Last Name" formControlName="lastNameFormCtrl" required> |
| 13 | + <md-error>This field is required</md-error> |
| 14 | + </md-input-container> |
| 15 | + <div> |
| 16 | + <button md-button mdStepperNext type="button">Next</button> |
| 17 | + </div> |
| 18 | + </md-step> |
22 | 19 |
|
23 | | - <md-step [disabled]="!formGroup.controls.formArray.controls[0].valid"> |
24 | | - <div [formGroupName]="1"> |
25 | | - <ng-template mdStepLabel> |
26 | | - <div>Fill out your phone number</div> |
27 | | - </ng-template> |
28 | | - <md-input-container> |
29 | | - <input mdInput placeholder="Phone number" formControlName="phoneFormCtrl" required> |
30 | | - <md-error>This field is required</md-error> |
31 | | - </md-input-container> |
32 | | - <div> |
33 | | - <button md-button mdStepperPrevious>Back</button> |
34 | | - <button md-button mdStepperNext>Next</button> |
35 | | - </div> |
36 | | - </div> |
37 | | - </md-step> |
| 20 | + <md-step formGroupName="1" |
| 21 | + [disabled]="formArray.hasError('invalid step') ? |
| 22 | + formArray.getError('invalid step').index <= 1 : false"> |
| 23 | + <ng-template mdStepLabel> |
| 24 | + <div>Fill out your phone number</div> |
| 25 | + </ng-template> |
| 26 | + <md-input-container> |
| 27 | + <input mdInput placeholder="Phone number" formControlName="phoneFormCtrl"> |
| 28 | + <md-error>This field is required</md-error> |
| 29 | + </md-input-container> |
| 30 | + <div> |
| 31 | + <button md-button mdStepperPrevious type="button">Back</button> |
| 32 | + <button md-button mdStepperNext type="button">Next</button> |
| 33 | + </div> |
| 34 | + </md-step> |
38 | 35 |
|
39 | | - <md-step [disabled]="!formGroup.controls.formArray.controls[1].valid"> |
40 | | - <ng-template mdStepLabel>Confirm your information</ng-template> |
41 | | - Everything seems correct. |
42 | | - <div> |
43 | | - <button md-button>Done</button> |
44 | | - </div> |
45 | | - </md-step> |
46 | | - </md-vertical-stepper> |
47 | | - </div> |
| 36 | + <md-step |
| 37 | + [disabled]="formArray.hasError('invalid step') ? |
| 38 | + formArray.getError('invalid step').index <= 2 : false"> |
| 39 | + <ng-template mdStepLabel>Confirm your information</ng-template> |
| 40 | + Everything seems correct. |
| 41 | + <div> |
| 42 | + <button md-button>Done</button> |
| 43 | + </div> |
| 44 | + </md-step> |
| 45 | + </md-vertical-stepper> |
48 | 46 | </form> |
49 | 47 |
|
50 | 48 | <h2>Horizontal Stepper Demo</h2> |
|
0 commit comments