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:
Brandy Carney
2015-12-16 15:43:38 -05:00
parent 3e5d360ebf
commit 0f57b1f64f
3 changed files with 34 additions and 24 deletions

View File

@@ -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();

View File

@@ -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>