Created
June 28, 2018 11:01
-
-
Save embarq/8ba44b37630cfafd5c7ec96c59ca2b08 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @Directive({ | |
| selector: '[openNextField]' | |
| }) | |
| /** | |
| * @example | |
| * <form> | |
| * <ion-list> | |
| * <ion-item> | |
| * <ion-label>Text field</ion-label> | |
| * <ion-input [openNextField]="selectFieldRef"></ion-input> | |
| * </ion-item> | |
| * <ion-item> | |
| * <ion-label>Select field</ion-label> | |
| * <ion-select #selectFieldRef> | |
| * <ion-option>1</ion-option> | |
| * <ion-option>2</ion-option> | |
| * </ion-select> | |
| * </ion-item> | |
| * </ion-list> | |
| * </form> | |
| */ | |
| export class OpenNextFieldDirective { | |
| @Input('openNextField') | |
| private nextFieldRef: Select | Datetime; | |
| private readonly tabKeyCode = 9; | |
| @HostListener('keyup', ['$event']) | |
| public handleNextKey(event) { | |
| if (event.keyCode === this.tabKeyCode && this.nextFieldRef != null) { | |
| this.nextFieldRef.open(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment