mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-23 05:58:26 +08:00
fix(): add event emitter to segment for ionchange
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import { Component, Element, HostElement, Listen, Prop, PropDidChange } from '@stencil/core';
|
import { Component, Element, HostElement, Listen, Prop, PropDidChange, EventEmitter, Event } from '@stencil/core';
|
||||||
|
|
||||||
import { SegmentButtonEvent } from '../../index';
|
import { SegmentButtonEvent } from '../../index';
|
||||||
|
|
||||||
@ -74,6 +74,8 @@ export class Segment {
|
|||||||
buttons: NodeListOf<HostElement>;
|
buttons: NodeListOf<HostElement>;
|
||||||
@Element() el: HTMLElement;
|
@Element() el: HTMLElement;
|
||||||
|
|
||||||
|
@Event() ionChange: EventEmitter;
|
||||||
|
|
||||||
@Prop({ state: true }) disabled: boolean = false;
|
@Prop({ state: true }) disabled: boolean = false;
|
||||||
|
|
||||||
@Prop({ state: true }) value: string;
|
@Prop({ state: true }) value: string;
|
||||||
@ -105,6 +107,11 @@ export class Segment {
|
|||||||
|
|
||||||
this.value = selectedButton.value;
|
this.value = selectedButton.value;
|
||||||
this.selectButton(this.value);
|
this.selectButton(this.value);
|
||||||
|
|
||||||
|
const event: SegmentEvent = {
|
||||||
|
'segment': this
|
||||||
|
};
|
||||||
|
this.ionChange.emit(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectButton(val: string) {
|
selectButton(val: string) {
|
||||||
@ -129,3 +136,7 @@ export class Segment {
|
|||||||
return <slot></slot>;
|
return <slot></slot>;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface SegmentEvent {
|
||||||
|
segment: Segment;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user