From 6a7c97d77e69aa2060e9a774964b3bcb0e1c94d4 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Sat, 13 Feb 2016 00:42:37 -0600 Subject: [PATCH] feat(select): cancel output event Closes #5439 --- ionic/components/select/select.ts | 13 +++++++++++-- ionic/components/select/test/single-value/index.ts | 13 +++++++++++++ ionic/components/select/test/single-value/main.html | 2 +- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ionic/components/select/select.ts b/ionic/components/select/select.ts index 09cce100546..adcfb6e70d4 100644 --- a/ionic/components/select/select.ts +++ b/ionic/components/select/select.ts @@ -150,11 +150,15 @@ export class Select { @Input() checked: any = false; /** - * @private * @output {any} Any expression you want to evaluate when the selection has changed */ @Output() change: EventEmitter = new EventEmitter(); + /** + * @output {any} Any expression you want to evaluate when the selection was cancelled + */ + @Output() cancel: EventEmitter = new EventEmitter(); + constructor( private _form: Form, private _elementRef: ElementRef, @@ -196,7 +200,12 @@ export class Select { // make sure their buttons array is removed from the options // and we create a new array for the alert's two buttons - alertOptions.buttons = [this.cancelText]; + alertOptions.buttons = [{ + text: this.cancelText, + handler: () => { + this.cancel.emit(null); + } + }]; // if the alertOptions didn't provide an title then use the label's text if (!alertOptions.title && this._item) { diff --git a/ionic/components/select/test/single-value/index.ts b/ionic/components/select/test/single-value/index.ts index 2b872328d5e..11f108b5fe3 100644 --- a/ionic/components/select/test/single-value/index.ts +++ b/ionic/components/select/test/single-value/index.ts @@ -5,6 +5,9 @@ import {App, Page} from '../../../../../ionic/ionic'; templateUrl: 'main.html' }) class E2EPage { + musicAlertOpts; + gender: string; + constructor() { this.musicAlertOpts = { title: '1994 Music', @@ -16,6 +19,14 @@ class E2EPage { }, 1500); } + gamingCancel() { + console.log('Gaming Select, Cancel'); + } + + gamingChange(selectedValue) { + console.log('Gaming Select, Change value:', selectedValue); + } + stpSelect() { console.log('STP selected') } @@ -30,6 +41,8 @@ class E2EPage { template: '' }) class E2EApp { + root; + constructor() { this.root = E2EPage; } diff --git a/ionic/components/select/test/single-value/main.html b/ionic/components/select/test/single-value/main.html index 404849ea92c..fdd7f3f72b3 100644 --- a/ionic/components/select/test/single-value/main.html +++ b/ionic/components/select/test/single-value/main.html @@ -14,7 +14,7 @@ Gaming - + NES Nintendo64 PlayStation