mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
refactor(segment): changed segment event emitter type to SegmentButton and update the change to emit value
Fixed tests to reflect this. References #819
This commit is contained in:
@ -55,7 +55,7 @@ import {isDefined} from '../../util/util';
|
||||
})
|
||||
export class SegmentButton {
|
||||
@Input() value: string;
|
||||
@Output() select: EventEmitter<any> = new EventEmitter();
|
||||
@Output() select: EventEmitter<SegmentButton> = new EventEmitter();
|
||||
|
||||
constructor(private _renderer: Renderer, private _elementRef: ElementRef) {}
|
||||
|
||||
@ -131,8 +131,8 @@ export class SegmentButton {
|
||||
selector: 'ion-segment'
|
||||
})
|
||||
export class Segment {
|
||||
@Output() change: EventEmitter<any> = new EventEmitter();
|
||||
@ContentChildren(SegmentButton) _buttons;
|
||||
@Output() change: EventEmitter<SegmentButton> = new EventEmitter();
|
||||
value: any;
|
||||
|
||||
constructor(
|
||||
@ -169,7 +169,7 @@ export class Segment {
|
||||
button.select.subscribe((selectedButton) => {
|
||||
this.writeValue(selectedButton.value);
|
||||
this.onChange(selectedButton.value);
|
||||
this.change.emit(selectedButton.value);
|
||||
this.change.emit(selectedButton);
|
||||
});
|
||||
|
||||
if (isDefined(this.value)) {
|
||||
|
@ -20,12 +20,12 @@ class MyApp {
|
||||
this.appType = 'free';
|
||||
}
|
||||
|
||||
onSegmentChanged(value) {
|
||||
console.log("Segment changed to", value);
|
||||
onSegmentChanged(segmentButton) {
|
||||
console.log("Segment changed to", segmentButton.value);
|
||||
}
|
||||
|
||||
onSegmentClicked(value) {
|
||||
console.log("Segment clicked", value);
|
||||
onSegmentSelected(segmentButton) {
|
||||
console.log("Segment selected", segmentButton.value);
|
||||
}
|
||||
|
||||
doSubmit(event) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
<ion-toolbar>
|
||||
<ion-segment id="segment" [(ngModel)]="relationship" (change)="onSegmentChanged($event)">
|
||||
<ion-segment-button value="friends" (click)="onSegmentClicked('friends')" class="e2eSegmentFriends">
|
||||
<ion-segment-button value="friends" (select)="onSegmentSelected($event)" class="e2eSegmentFriends">
|
||||
Friends
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="enemies" (click)="onSegmentClicked('enemies')">
|
||||
<ion-segment-button value="enemies" (select)="onSegmentSelected($event)">
|
||||
Enemies
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
|
Reference in New Issue
Block a user