Skip to content

Commit d8b53ef

Browse files
committed
Add enabling/disabling linear state of demo
1 parent e648c0e commit d8b53ef

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

src/cdk/stepper/stepper.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ export class CdkStep {
8383
selector: 'cdk-stepper',
8484
host: {
8585
'(focus)': '_focusStep()',
86-
'(keydown)': '_onKeydown($event)',
87-
'[linear]': 'linear',
86+
'(keydown)': '_onKeydown($event)'
8887
},
8988
})
9089
export class CdkStepper {
@@ -97,9 +96,7 @@ export class CdkStepper {
9796
/** Whether the validity of previous steps should be checked or not. */
9897
@Input()
9998
get linear() { return this._linear; }
100-
set linear(value: any) {
101-
this._linear = coerceBooleanProperty(value);
102-
}
99+
set linear(value: any) { this._linear = coerceBooleanProperty(value); }
103100
private _linear = false;
104101

105102
/** The index of the selected step. */

src/demo-app/stepper/stepper-demo.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<h2>Linear Vertical Stepper Demo</h2>
2+
<md-checkbox [(ngModel)]="isNonLinear">Disable linear mode</md-checkbox>
23
<form [formGroup]="formGroup">
3-
<md-vertical-stepper formArrayName="formArray" linear>
4+
<md-vertical-stepper formArrayName="formArray" [linear]="!isNonLinear">
45
<md-step formGroupName="0" [stepControl]="formArray.get([0])">
56
<ng-template mdStepLabel>Fill out your name</ng-template>
67
<md-input-container>

src/demo-app/stepper/stepper-demo.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import {Validators, FormBuilder, FormGroup} from '@angular/forms';
55
moduleId: module.id,
66
selector: 'stepper-demo',
77
templateUrl: 'stepper-demo.html',
8-
styleUrls: ['stepper-demo.scss'],
8+
styleUrls: ['stepper-demo.scss']
99
})
1010
export class StepperDemo {
1111
formGroup: FormGroup;
12+
isNonLinear = false;
1213

1314
steps = [
1415
{label: 'Confirm your name', content: 'Last name, First name.'},

src/lib/stepper/stepper.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ export class MdStep extends CdkStep implements ErrorOptions {
5555
errorStateMatcher = (control: FormControl, form: FormGroupDirective | NgForm) => {
5656
let originalErrorState = this._originalErrorStateMatcher(control, form);
5757

58-
/**
59-
* Custom error state checks for the validity of form that is not submitted or touched
60-
* since user can trigger a form change by calling for another step without directly
61-
* interacting with the current form.
62-
*/
58+
// Custom error state checks for the validity of form that is not submitted or touched
59+
// since user can trigger a form change by calling for another step without directly
60+
// interacting with the current form.
6361
let customErrorState = control.invalid && this.interacted;
6462

6563
return originalErrorState || customErrorState;

0 commit comments

Comments
 (0)