test: fix all tests to remove app.getComponent

This commit is contained in:
Brandy Carney
2016-05-20 21:07:29 -04:00
parent 4ee0ca4928
commit 6592981aac
9 changed files with 96 additions and 87 deletions

View File

@ -1,40 +1,42 @@
import {Validators, Control, ControlGroup} from '@angular/common';
import {Http} from '@angular/http';
import {App, Page, IonicApp, NavController} from '../../../../../src';
import {ViewChild} from '@angular/core';
import {App, Page, NavController, Slides} from '../../../../../src';
@Page({
templateUrl: 'main.html',
})
class SegmentPage {
constructor(app: IonicApp) {
this.app = app;
@ViewChild('loopSlider') sliderComponent: Slides;
selectedSegment = "first";
slides = [
{
id: "first",
title: "First Slide"
},
{
id: "second",
title: "Second Slide"
},
{
id: "third",
title: "Third Slide"
}
];
constructor() {
this.selectedSegment = "first";
this.slides = [
{
id: "first",
title: "First Slide"
},
{
id: "second",
title: "Second Slide"
},
{
id: "third",
title: "Third Slide"
}
];
}
onSegmentChanged(segmentButton) {
console.log("Segment changed to", segmentButton.value);
this.sliderComponent = this.app.getComponent('loopSlider');
const selectedIndex = this.slides.findIndex((slide) => {
return slide.id === segmentButton.value;
});
this.sliderComponent.slider.slideTo(selectedIndex);
this.sliderComponent.slideTo(selectedIndex);
}
onSlideChanged(slider) {
@ -47,11 +49,12 @@ class SegmentPage {
@App({
pages: [SegmentPage],
template: `<ion-nav [root]="root"></ion-nav>`
})
class MyApp {
root = SegmentPage;
constructor() {
this.root = SegmentPage;
}
}

View File

@ -19,7 +19,7 @@
<ion-content padding>
<ion-slides (change)="onSlideChanged($event)" id="loopSlider">
<ion-slides (change)="onSlideChanged($event)" #loopSlider>
<ion-slide *ngFor="let slide of slides">
<h1>{{ slide.title }}</h1>
</ion-slide>