mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(select): emit the ionSelect option when selecting an option
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@ export class E2EPage {
|
||||
console.log('onSubmit', data);
|
||||
}
|
||||
|
||||
toppingsSelect(selectedValue: any) {
|
||||
console.log('Selected', selectedValue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user