mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
test(e2e): searchbar/nav
This commit is contained in:
@@ -1,158 +0,0 @@
|
||||
import { Component, NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { IonicApp, IonicModule, ModalController, NavController, NavParams, ViewController } from '../../../..';
|
||||
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class MainPage {
|
||||
constructor(public navCtrl: NavController) { }
|
||||
|
||||
goToSecond() {
|
||||
this.navCtrl.push(SearchPage);
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
templateUrl: 'modal.html'
|
||||
})
|
||||
export class ModalPage {
|
||||
constructor(public viewCtrl: ViewController) {}
|
||||
close() {
|
||||
this.viewCtrl.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
templateUrl: 'search.html'
|
||||
})
|
||||
export class SearchPage {
|
||||
items: string[];
|
||||
|
||||
constructor(public navCtrl: NavController, public modalCtrl: ModalController) {
|
||||
this.initializeItems();
|
||||
}
|
||||
|
||||
showDetail(item: any) {
|
||||
this.navCtrl.push(DetailPage, {city: item});
|
||||
}
|
||||
|
||||
initializeItems() {
|
||||
this.items = [
|
||||
'Amsterdam',
|
||||
'Bogota',
|
||||
'Buenos Aires',
|
||||
'Cairo',
|
||||
'Dhaka',
|
||||
'Edinburgh',
|
||||
'Geneva',
|
||||
'Genoa',
|
||||
'Glasglow',
|
||||
'Hanoi',
|
||||
'Hong Kong',
|
||||
'Islamabad',
|
||||
'Istanbul',
|
||||
'Jakarta',
|
||||
'Kiel',
|
||||
'Kyoto',
|
||||
'Le Havre',
|
||||
'Lebanon',
|
||||
'Lhasa',
|
||||
'Lima',
|
||||
'London',
|
||||
'Los Angeles',
|
||||
'Madrid',
|
||||
'Manila',
|
||||
'New York',
|
||||
'Olympia',
|
||||
'Oslo',
|
||||
'Panama City',
|
||||
'Peking',
|
||||
'Philadelphia',
|
||||
'San Francisco',
|
||||
'Seoul',
|
||||
'Taipeh',
|
||||
'Tel Aviv',
|
||||
'Tokio',
|
||||
'Uelzen',
|
||||
'Washington'
|
||||
];
|
||||
}
|
||||
|
||||
getItems(ev: any) {
|
||||
// Reset items back to all of the items
|
||||
this.initializeItems();
|
||||
|
||||
// set q to the value of the searchbar
|
||||
var q = ev.target.value;
|
||||
|
||||
// if the value is an empty string don't filter the items
|
||||
if (!q || q.trim() === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.items = this.items.filter((v) => {
|
||||
if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
openModal() {
|
||||
let modal = this.modalCtrl.create(ModalPage);
|
||||
modal.present();
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
templateUrl: 'detail.html'
|
||||
})
|
||||
export class DetailPage {
|
||||
city: string;
|
||||
|
||||
constructor(private _navParams: NavParams) {
|
||||
this.city = _navParams.get('city');
|
||||
}
|
||||
}
|
||||
|
||||
@Component({
|
||||
templateUrl: 'tabs.html'
|
||||
})
|
||||
export class TabsPage {
|
||||
mainPage = MainPage;
|
||||
searchPage = SearchPage;
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="root"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
root = TabsPage;
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
MainPage,
|
||||
SearchPage,
|
||||
ModalPage,
|
||||
DetailPage,
|
||||
TabsPage
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
IonicModule.forRoot(E2EApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EApp,
|
||||
MainPage,
|
||||
SearchPage,
|
||||
ModalPage,
|
||||
DetailPage,
|
||||
TabsPage
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
8
src/components/searchbar/test/nav/app/app.component.ts
Normal file
8
src/components/searchbar/test/nav/app/app.component.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: '<ion-nav [root]="root"></ion-nav>'
|
||||
})
|
||||
export class E2EApp {
|
||||
root = 'TabsPage';
|
||||
}
|
||||
28
src/components/searchbar/test/nav/app/app.module.ts
Normal file
28
src/components/searchbar/test/nav/app/app.module.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { IonicApp, IonicModule } from '../../../../..';
|
||||
|
||||
import { E2EApp } from './app.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
E2EApp,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
IonicModule.forRoot(E2EApp, {}, {
|
||||
links: [
|
||||
{ loadChildren: '../pages/detail-page/detail.module#DetailPageModule', name: 'DetailPage' },
|
||||
{ loadChildren: '../pages/main-page/main.module#MainPageModule', name: 'MainPage' },
|
||||
{ loadChildren: '../pages/modal-page/modal.module#ModalPageModule', name: 'ModalPage' },
|
||||
{ loadChildren: '../pages/search-page/search.module#SearchPageModule', name: 'SearchPage' },
|
||||
{ loadChildren: '../pages/tabs-page/tabs.module#TabsPageModule', name: 'TabsPage' },
|
||||
]
|
||||
})
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
E2EApp,
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { DetailPage } from './detail';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
DetailPage,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(DetailPage)
|
||||
],
|
||||
entryComponents: [
|
||||
DetailPage,
|
||||
]
|
||||
})
|
||||
export class DetailPageModule {}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { NavParams } from '../../../../../..';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'detail.html'
|
||||
})
|
||||
export class DetailPage {
|
||||
city: string;
|
||||
|
||||
constructor(private _navParams: NavParams) {
|
||||
this.city = _navParams.get('city');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { MainPage } from './main';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
MainPage,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(MainPage)
|
||||
],
|
||||
entryComponents: [
|
||||
MainPage,
|
||||
]
|
||||
})
|
||||
export class MainPageModule {}
|
||||
13
src/components/searchbar/test/nav/pages/main-page/main.ts
Normal file
13
src/components/searchbar/test/nav/pages/main-page/main.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { NavController } from '../../../../../..';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'main.html'
|
||||
})
|
||||
export class MainPage {
|
||||
constructor(public navCtrl: NavController) { }
|
||||
|
||||
goToSecond() {
|
||||
this.navCtrl.push('SearchPage');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { ModalPage } from './modal';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
ModalPage,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(ModalPage)
|
||||
],
|
||||
entryComponents: [
|
||||
ModalPage,
|
||||
]
|
||||
})
|
||||
export class ModalPageModule {}
|
||||
12
src/components/searchbar/test/nav/pages/modal-page/modal.ts
Normal file
12
src/components/searchbar/test/nav/pages/modal-page/modal.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ViewController } from '../../../../../..';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'modal.html'
|
||||
})
|
||||
export class ModalPage {
|
||||
constructor(public viewCtrl: ViewController) {}
|
||||
close() {
|
||||
this.viewCtrl.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { SearchPage } from './search';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
SearchPage,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(SearchPage)
|
||||
],
|
||||
entryComponents: [
|
||||
SearchPage,
|
||||
]
|
||||
})
|
||||
export class SearchPageModule {}
|
||||
@@ -0,0 +1,84 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { NavController, ModalController } from '../../../../../..';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'search.html'
|
||||
})
|
||||
export class SearchPage {
|
||||
items: string[];
|
||||
|
||||
constructor(public navCtrl: NavController, public modalCtrl: ModalController) {
|
||||
this.initializeItems();
|
||||
}
|
||||
|
||||
showDetail(item: any) {
|
||||
this.navCtrl.push('DetailPage', {city: item});
|
||||
}
|
||||
|
||||
initializeItems() {
|
||||
this.items = [
|
||||
'Amsterdam',
|
||||
'Bogota',
|
||||
'Buenos Aires',
|
||||
'Cairo',
|
||||
'Dhaka',
|
||||
'Edinburgh',
|
||||
'Geneva',
|
||||
'Genoa',
|
||||
'Glasglow',
|
||||
'Hanoi',
|
||||
'Hong Kong',
|
||||
'Islamabad',
|
||||
'Istanbul',
|
||||
'Jakarta',
|
||||
'Kiel',
|
||||
'Kyoto',
|
||||
'Le Havre',
|
||||
'Lebanon',
|
||||
'Lhasa',
|
||||
'Lima',
|
||||
'London',
|
||||
'Los Angeles',
|
||||
'Madrid',
|
||||
'Manila',
|
||||
'New York',
|
||||
'Olympia',
|
||||
'Oslo',
|
||||
'Panama City',
|
||||
'Peking',
|
||||
'Philadelphia',
|
||||
'San Francisco',
|
||||
'Seoul',
|
||||
'Taipeh',
|
||||
'Tel Aviv',
|
||||
'Tokio',
|
||||
'Uelzen',
|
||||
'Washington'
|
||||
];
|
||||
}
|
||||
|
||||
getItems(ev: any) {
|
||||
// Reset items back to all of the items
|
||||
this.initializeItems();
|
||||
|
||||
// set q to the value of the searchbar
|
||||
var q = ev.target.value;
|
||||
|
||||
// if the value is an empty string don't filter the items
|
||||
if (!q || q.trim() === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.items = this.items.filter((v) => {
|
||||
if (v.toLowerCase().indexOf(q.toLowerCase()) > -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
openModal() {
|
||||
let modal = this.modalCtrl.create('ModalPage');
|
||||
modal.present();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DeepLinkModule } from '../../../../../..';
|
||||
|
||||
import { TabsPage } from './tabs';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
TabsPage,
|
||||
],
|
||||
imports: [
|
||||
DeepLinkModule.forChild(TabsPage)
|
||||
],
|
||||
entryComponents: [
|
||||
TabsPage,
|
||||
]
|
||||
})
|
||||
export class TabsPageModule {}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'tabs.html'
|
||||
})
|
||||
export class TabsPage {
|
||||
mainPage = 'MainPage';
|
||||
searchPage = 'SearchPage';
|
||||
}
|
||||
Reference in New Issue
Block a user