mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
feat(segment): added change event to segment which emits the value
Updated the API docs for segment to include change & click, and updated some of the function descriptions, removed an unused function. Added the change & click events to the test case.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {FORM_DIRECTIVES, FormBuilder, Validators, Control, ControlGroup} from 'angular2/common';
|
||||
|
||||
import {App} from 'ionic/ionic';
|
||||
import {App, IonicApp} from 'ionic/ionic';
|
||||
|
||||
|
||||
@App({
|
||||
@@ -9,7 +9,8 @@ import {App} from 'ionic/ionic';
|
||||
directives: [FORM_DIRECTIVES]
|
||||
})
|
||||
class MyApp {
|
||||
constructor(fb: FormBuilder) {
|
||||
constructor(fb: FormBuilder, app: IonicApp) {
|
||||
this.app = app;
|
||||
this.myForm = fb.group({
|
||||
mapStyle: ['hybrid', Validators.required]
|
||||
});
|
||||
@@ -19,6 +20,14 @@ class MyApp {
|
||||
this.appType = 'free';
|
||||
}
|
||||
|
||||
onSegmentChanged(value) {
|
||||
console.log("Segment changed to", value);
|
||||
}
|
||||
|
||||
onSegmentClicked(value) {
|
||||
console.log("Segment clicked", value);
|
||||
}
|
||||
|
||||
doSubmit(event) {
|
||||
console.log('Submitting form', this.myForm.value);
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<ion-toolbar>
|
||||
<ion-segment [(ngModel)]="relationship">
|
||||
<ion-segment-button value="friends" class="e2eSegmentFriends">
|
||||
<ion-segment id="segment" [(ngModel)]="relationship" (change)="onSegmentChanged($event)">
|
||||
<ion-segment-button value="friends" (click)="onSegmentClicked('friends')" class="e2eSegmentFriends">
|
||||
Friends
|
||||
</ion-segment-button>
|
||||
<ion-segment-button value="enemies">
|
||||
<ion-segment-button value="enemies" (click)="onSegmentClicked('enemies')">
|
||||
Enemies
|
||||
</ion-segment-button>
|
||||
</ion-segment>
|
||||
|
||||
Reference in New Issue
Block a user