fix(select): firing events properly in popover interface

This commit is contained in:
Szymon Stasik
2017-05-03 05:27:13 -05:00
committed by Manu MA
parent 19020108aa
commit 59dd853f54
2 changed files with 10 additions and 7 deletions

View File

@ -8,6 +8,7 @@ export interface SelectPopoverOption {
value: string;
disabled: boolean;
checked: boolean;
handler?: Function;
}
/** @hidden */
@ -30,6 +31,10 @@ export class SelectPopover implements OnInit {
}
public set value(value: any) {
let checkedOption = this.options.find(option => option.value === value);
if (checkedOption && checkedOption.handler) {
checkedOption.handler();
}
this.viewController.dismiss(value);
}

View File

@ -301,7 +301,11 @@ export class Select extends BaseInput<any> implements OnDestroy {
text: input.text,
checked: input.selected,
disabled: input.disabled,
value: input.value
value: input.value,
handler: () => {
this.value = input.value;
input.ionSelect.emit(input.value);
}
}));
overlay = new Popover(this._app, SelectPopover, {
@ -368,12 +372,6 @@ export class Select extends BaseInput<any> implements OnDestroy {
overlay.onDidDismiss((value: any) => {
this._fireBlur();
if (this.interface === 'popover' && value) {
this.value = value;
this.ionChange.emit(value);
}
this._overlay = undefined;
});