forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stepper): Add support for linear stepper (angular#6116)
* Add form controls and custom error state matcher * Modify form controls for stepper-demo and add custom validator * Move custom step validation function so that users can simply import and use * Implement @input() stepControl for each step * Add linear attribute to stepper * Add enabling/disabling linear state of demo
- Loading branch information
1 parent
9958a88
commit 5b2522b
Showing
5 changed files
with
140 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,39 @@ | ||
import {Component} from '@angular/core'; | ||
import {Validators, FormBuilder, FormGroup} from '@angular/forms'; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'stepper-demo', | ||
templateUrl: 'stepper-demo.html', | ||
styleUrls: ['stepper-demo.scss'], | ||
styleUrls: ['stepper-demo.scss'] | ||
}) | ||
export class StepperDemo { | ||
formGroup: FormGroup; | ||
isNonLinear = false; | ||
|
||
steps = [ | ||
{label: 'Confirm your name', content: 'Last name, First name.'}, | ||
{label: 'Confirm your contact information', content: '123-456-7890'}, | ||
{label: 'Confirm your address', content: '1600 Amphitheater Pkwy MTV'}, | ||
{label: 'You are now done', content: 'Finished!'} | ||
]; | ||
|
||
/** Returns a FormArray with the name 'formArray'. */ | ||
get formArray() { return this.formGroup.get('formArray'); } | ||
|
||
constructor(private _formBuilder: FormBuilder) { } | ||
|
||
ngOnInit() { | ||
this.formGroup = this._formBuilder.group({ | ||
formArray: this._formBuilder.array([ | ||
this._formBuilder.group({ | ||
firstNameFormCtrl: ['', Validators.required], | ||
lastNameFormCtrl: ['', Validators.required], | ||
}), | ||
this._formBuilder.group({ | ||
phoneFormCtrl: [''], | ||
}) | ||
]) | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters