fix(select): emit the ionSelect option when selecting an option

This commit is contained in:
Brandy Carney
2016-10-21 19:11:02 -04:00
parent f43539ebc7
commit 2eed5e24c2
6 changed files with 32 additions and 7 deletions

View File

@@ -296,6 +296,7 @@ export class Select extends Ion implements AfterContentInit, ControlValueAccesso
handler: () => {
this.onChange(input.value);
this.ionChange.emit(input.value);
input.ionSelect.emit(input.value);
}
};
}));
@@ -319,7 +320,14 @@ export class Select extends Ion implements AfterContentInit, ControlValueAccesso
label: input.text,
value: input.value,
checked: input.selected,
disabled: input.disabled
disabled: input.disabled,
handler: (selectedOption: any) => {
// Only emit the select event if it is being checked
// For multi selects this won't emit when unchecking
if (selectedOption.checked) {
input.ionSelect.emit(input.value);
}
}
};
});

View File

@@ -41,6 +41,10 @@ export class E2EPage {
console.log('onSubmit', data);
}
toppingsSelect(selectedValue: any) {
console.log('Selected', selectedValue);
}
}

View File

@@ -19,7 +19,7 @@
<ion-option value="mushrooms">Mushrooms</ion-option>
<ion-option value="onions">Onions</ion-option>
<ion-option value="pepperoni">Pepperoni</ion-option>
<ion-option value="pineapple">Pineapple</ion-option>
<ion-option value="pineapple" (ionSelect)="toppingsSelect($event)">Pineapple</ion-option>
<ion-option value="sausage">Sausage</ion-option>
<ion-option value="Spinach">Spinach</ion-option>
</ion-select>

View File

@@ -67,8 +67,12 @@ export class E2EPage {
console.log('Gaming Select, Change value:', selectedValue);
}
stpSelect() {
console.log('STP selected');
musicSelect(selectedValue: any) {
console.log('Music selected', selectedValue);
}
notificationSelect(selectedValue: any) {
console.log('Notification select', selectedValue);
}
statusChange(ev: string) {

View File

@@ -48,7 +48,7 @@
<ion-option value="enable">Enable</ion-option>
<ion-option value="mute">Mute</ion-option>
<ion-option value="mute_week">Mute for a week</ion-option>
<ion-option value="mute_year">Mute for a year</ion-option>
<ion-option value="mute_year" (ionSelect)="notificationSelect($event)">Mute for a year</ion-option>
</ion-select>
</ion-item>
@@ -61,7 +61,7 @@
<ion-option>Pearl Jam</ion-option>
<ion-option>Smashing Pumpkins</ion-option>
<ion-option>Soundgarden</ion-option>
<ion-option (ionSelect)="stpSelect()">Stone Temple Pilots</ion-option>
<ion-option (ionSelect)="musicSelect($event)">Stone Temple Pilots</ion-option>
</ion-select>
</ion-item>