Ionic2 with checkbox - ionic2

I might sound old, but i am new for ionic 2. i wrote a code in ionic 2 for checkbox and it is working well but how do i retrieve the count of the checked boxes
Below is the code i have.
checklist.ts code
import { Component } from '#angular/core';
import { NavController, NavParams, Alert } from 'ionic-angular';
#Component({
templateUrl: 'build/pages/checklist/checklist.html',
})
export class ChecklistPage {
checklist:any;
constructor(public nav: NavController, public navParams: NavParams) {
this.checklist = this.navParams.get('checklist');
}
addItem(): void {
let prompt = Alert.create({
title: 'Add Item',
message: 'Enter the name of the task for this checklist below:',
inputs:[
{
name: 'name'
}
],
buttons:[
{
text: 'Cancel'
},
{
text: 'Save',
handler: data => {
this.checklist.addItem(data.name);
}
}
]
});
this.nav.present(prompt);
}
toggleItem(item): void {
this.checklist.toggleItem(item);
}
removeItem(item): void {
this.checklist.removeItem(item);
}
renameItem(item): void {
let prompt = Alert.create({
title: 'Rename Item',
message: 'Enter the new name of the task for this checklist below:',
inputs: [
{
name: 'name'
}
],
buttons: [
{
text: 'Cancel'
},
{
text: 'Save',
handler: data => {
this.checklist.renameItem(item,data.name);
}
}
]
});
this.nav.present(prompt);
}
checkallItems(): void {
this.checklist.items.forEach((item) => {
if(!item.checked){
this.checklist.toggleItem(item);
}
});
}
uncheckItems(): void {
this.checklist.items.forEach((item) => {
if(item.checked){
this.checklist.toggleItem(item);
}
});
}
}
checklist.html
<ion-header>
<ion-navbar secondary>
<ion-title>{{checklist.title}} #(checkeditem)/{{checklist.items.length}}</ion-title>
<ion-buttons end>
<button (click)="checkallItems()">
<ion-icon name="checkbox"></ion-icon>
</button>
<button (click)="uncheckItems()">
<ion-icon name="refresh-circle"></ion-icon>
</button>
<button (click)="addItem()">
<ion-icon name="add-circle"></ion-icon>
</button>
</ion-buttons>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list no-lines>
<ion-item-sliding *ngFor="let item of checklist.items" class="home-sliding-item">
<ion-item>
<ion-label>{{item.title}}</ion-label>
<ion-checkbox [checked]="item.checked" (click)="toggleItem(item)" class="checklist-item"></ion-checkbox>
</ion-item>
<ion-item-options>
<button light (click)="renameItem(item)">
<ion-icon name="clipboard"></ion-icon>Edit
</button>
<button danger (click)="removeItem(item)">
<ion-icon name="trash"></ion-icon>Delete
</button>
</ion-item-options>
</ion-item-sliding>
</ion-list>
</ion-content>

You can add a method in your ChecklistPage like this:
public getItemsCount(): number {
let count= 0;
for(let i=0; i<this.checklist.items.length; i++) {
if(this.checklist.items[i].checked){
count++;
}
}
return count;
}
Or following the checkallItems() method:
public getItemsCount(): number {
let count= 0;
this.checklist.items.forEach((item) => {
if(item.checked){
count++;
}
});
return count;
}
And then in your view:
<ion-title>{{checklist.title}} #{{getItemsCount()}}/{{checklist.items.length}}</ion-title>

Related

Issue in load Web API data in grid ionic framework

i m new in ionic and i want to load my web api data in grid ionic so below is my code.
grid.html
<ion-header>
<ion-navbar>
<button ion-button menuToggle>
<ion-icon name="menu"></ion-icon>
</button>
<ion-title>Grid Demo</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-refresher (ionRefresh)="doRefresh($event)">
<ion-refresher-content></ion-refresher-content>
</ion-refresher>
<ion-grid>
<ion-row *ngFor="let product of products">
<ion-col width-50 >
<h1>{{product.title}}</h1>
</ion-col>
</ion-row>
</ion-grid>
<ion-infinite-scroll (ionInfinite)="doInfinite($event)">
<ion-infinite-scroll-content></ion-infinite-scroll-content>
</ion-infinite-scroll>
</ion-content>
grid.ts
import { Component } from '#angular/core';
import { NavController, NavParams, LoadingController } from 'ionic-angular';
import { ProductListProvider } from '../../providers/product/product'
#Component({
templateUrl: 'grid.html',
providers:[ProductListProvider]
})
export class GridHttpPage {
public response: any;
public products: any =[];
public count: any;
public loader: any;
public page: number = 0;
public isLoading: boolean =true;
public totalItem: number ;
doRefresh(refresher) {
console.log('Begin async operation', refresher);
setTimeout(() => {
this.page=0;
this.loadData(true);
console.log('Async operation has ended');
refresher.complete();
}, 2000);
}
constructor(public navCtrl: NavController, public navParams: NavParams, public personListProvider: ProductListProvider, public loadingCtrl: LoadingController) {
this.count = 0;
this.loadData(this.isLoading);
}
presentLoading() {
this.loader = this.loadingCtrl.create({
// spinner: 'hide',
content: "Please wait...",
// duration: 3000,
// showBackdrop: true,
// enableBackdropDismiss: true,
// dismissOnPageChange: true
});
this.loader.onDidDismiss(() => {
// console.log('Dismissed loading');
});
this.loader.present();
}
loadData(isLoading) {
if(isLoading==true)
{
this.presentLoading();
}
this.page ++;
this.personListProvider.load(this.page)
.then(data => {
this.response = data;
this.totalItem = this.response.listing.total;
//this.products = this.response.listing.data;
for (let i = 0; i < this.response.listing.data.length; i++) {
this.products.push(this.response.listing.data[i]);
// console.log(this.response.listing.data[i]);
}
if(isLoading==true)
{
this.loader.dismiss();
}
console.log(this.response.listing);
console.log(this.products);
console.log(this.totalItem);
});
}
doInfinite(infiniteScroll) {
console.log('Begin async operation');
setTimeout(() => {
// for (let i = 0; i < 30; i++) {
// this.items.push( this.items.length );
// }
if(this.products.length <= this.totalItem )
{
this.loadData(false);
}
console.log('Async operation has ended');
infiniteScroll.complete();
}, 500);
}
}
When i run above code i get following type of output Refer screenshots.
GridView
It display single column list i want to display in 2 column so any idea how can i display in two column in gridview ionic?
I got solution
Make change in grid.ts file
rows: any;
in loadata funtion
loadData(isLoading) {
if(isLoading==true)
{
this.presentLoading();
}
this.page ++;
this.personListProvider.load(this.page)
.then(data => {
this.response = data;
this.totalItem = this.response.listing.total;
for (let i = 0; i < this.response.listing.data.length; i++) {
this.products.push(this.response.listing.data[i]);
}
this.rows = Array.from(Array(Math.ceil(this.products.length / 2)).keys());
if(isLoading==true)
{
this.loader.dismiss();
}
console.log(this.response.listing);
console.log(this.products);
console.log(this.totalItem);
});
}
in grid.html change as follows
<ion-grid>
<ion-row *ngFor="let i of rows">
<ion-col *ngFor="let product of products | slice:(i*2):(i+1)*2" width-50 (click)="openDetailPage(product)">
<ion-card>
<ion-avatar item-left>
<img src="{{product.medium_image}}" />
</ion-avatar>
<ion-card-content>
<ion-card-title>
<h6>{{product.title}}</h6>
<p> <b>Price: </b> {{product.price}}</p>
</ion-card-title>
</ion-card-content>
</ion-card>
</ion-col>
</ion-row>
</ion-grid>

ionic 2 Side menu and log out and back key navigation

I am trying to achieve a log out functionality. I am using FB authentication. My problem here is after I do a logout successfully(This happens from the Side menu ) I return to the Login Screen. But now if I tap the device's back button it is taking me to the homepage(. Any idea how to prevent this ?
This is my app.component.ts
import { Component, ViewChild } from '#angular/core';
import { Platform, Nav, AlertController } from 'ionic-angular';
import { StatusBar } from '#ionic-native/status-bar';
import { SplashScreen } from '#ionic-native/splash-screen';
import { LoginPage } from '../pages/login/login';
import { NativeStorage } from '#ionic-native/native-storage';
import { TabsPage } from '../pages/tabs/tabs';
import { Facebook } from 'ionic-native';
#Component({
templateUrl: 'app.html',
})
export class MyApp {
#ViewChild(Nav) nav: Nav;
rootPage: any = LoginPage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private nativeStorage: NativeStorage, private alertCtrl: AlertController) {
platform.ready().then(() => platform.ready().then(() => {
this.nativeStorage.getItem("userId").then((data) => {
console.log(data.userExists);
this.rootPage = TabsPage;
this.nav.push(TabsPage);
}, (error) => {
console.log("No data in storage");
this.nav.push(LoginPage);
})
statusBar.styleDefault();
splashScreen.hide();
})
)
}
presentConfirm() {
let alert = this.alertCtrl.create({
title: "Confirm Logout",
message: "Do you really really want to quit this awesome app?",
buttons: [{
text: 'Nah! Just Kidding!', role: 'cancel', handler: () => {
}
},
{
text: "Ok",
handler: () => {
this.nativeStorage.clear();
this.nav.push(LoginPage);
this.rootPage = LoginPage;
Facebook.logout().then((response) => {
}, (error) => {
})
}
}]
});
alert.present();
}
}
This is my login page. Login.ts
import { Component } from '#angular/core';
import { NavController } from 'ionic-angular';
import { Facebook } from 'ionic-native';
import { NativeStorage } from '#ionic-native/native-storage';
import { TabsPage } from '../tabs/tabs'
#Component({
selector: 'login-home',
templateUrl: 'login.html'
})
export class LoginPage {
constructor(public navCtrl: NavController, private nativeStorage: NativeStorage) {
}
FBLogin() {
//this.navCtrl.push(TabsPage); - To be used on browser environment
Facebook.login(['email']).then((response) => {
Facebook.getLoginStatus().then((response) => {
if (response.status == 'connected') {
this.navCtrl.push(TabsPage); // - to be used on device
console.log("Setting Storage")
this.nativeStorage.setItem("userId", { userExists: true });
Facebook.api('/' + response.authResponse.userID + '?fields=id,name,gender', []).then((response) => {
}, (error) => {
alert(error)
})
}
else
alert("Not Logged in");
})
}, (error) => {
console.log((error));
})
}
}
This is my Menu
<ion-menu swipeEnabled="false" side="right" [content]="content">
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
<ion-content>
<ion-list>
<p> </p>
<button menuClose padding-top ion-item> Test 1 </button>
<button menuClose ion-item> Test 2 </button>
<button menuClose ion-item (click)="presentConfirm()"><ion-icon name="power"></ion-icon> Logout </button>
</ion-list>
</ion-content>
</ion-menu>
<ion-nav id="nav" [root]="rootPage" #content swipe-back-enabled="false"></ion-nav>
Your issue is you are doing:
this.nav.push(LoginPage);
in your logout handler.
This means LoginPage is added on top of your old navigation stack. You need to set a new stack and set LoginPage as root.
Do :
this.nav.setRoot(LoginPage);

PopoverCmp ionViewPreLoad error: No component factory found for SearchJobsPopOverPage

I am in the process of upgrading from Ionic 2 beta to rc3. I have the following components that were working, but there must be something I need to do to make it fit with rc3.
When the user clicks an icon, it invokes the following function inorder to show a popover.
presentPopover(event: Event): void {
this.popover = this.popoverController.create(SearchJobsPopOverPage, {
ev: event
});
this.popover.present();
}
SearchJobsPopOverPage
import { Component } from '#angular/core';
import { NavController, ViewController, NavParams, Events } from 'ionic-angular';
import { MapPage } from '../map/map';
import { CategoryPage } from '../category/category';
import { JobModel } from '../model/jobModel';
import { ReviewPage } from '../review/review';
import { RatingModel } from '../model/ratingModel';
import { PersonModel } from '../model/personModel';
import { DateTimePage } from '../datetime/datetime';
#Component({
//selector: 'searchjobspopover',
template: `
<ion-content padding id="search-popover">
<ion-list>
<ion-row>
<ion-col>
<div style="text-align:center">
<div id="pinButton"><button ion-button class="search-popover-button" (click)="presentFilterMap()" color="danger"><ion-icon class="search-popover-icon" name="pin"></ion-icon></button></div>
<p>Location</p>
</div>
</ion-col>
<ion-col>
<div style="text-align:center">
<div id="pinButton"><button ion-button class="search-popover-button" (click)="presentFilterCategories()" primary><ion-icon class="search-popover-icon" name="happy"></ion-icon></button></div>
<p>Sectors</p>
</div>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<div style="text-align:center">
<div id="pinButton"><button ion-button class="search-popover-button search-button-star" (click)="presentFilterRating()"><ion-icon class="search-popover-icon" name="star"></ion-icon></button></div>
<p>Rating</p>
</div>
</ion-col>
<ion-col>
<div style="text-align:center">
<div id="pinButton"><button ion-button class="search-popover-button" (click)="presentFilterTime()" color="secondary"><ion-icon class="search-popover-icon" name="time"></ion-icon></button></div>
<p>Last Online</p>
</div>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<div style="text-align:center">
<div id="pinButton"><button ion-button class="search-popover-button" (click)="clearFilters()" color="light"><ion-icon class="search-popover-icon" name="trash"></ion-icon></button></div>
<p>Clear Filters</p>
</div>
</ion-col>
</ion-row>
</ion-list>
</ion-content>
`
})
export class SearchJobsPopOverPage {
public nav: NavController = null;
public jobModel: JobModel = null;
public events: Events = null;
public ratingModel: RatingModel = null;
public personModelLoggedIn: PersonModel = null;
public lastOnline: number = null;
constructor(public navParams: NavParams, nav: NavController, public viewCtrl: ViewController, events: Events) {
this.events = events;
this.nav = nav;
this.jobModel = navParams.get('jobModel');
this.lastOnline = navParams.get('lastOnline');
this.personModelLoggedIn = navParams.get('personModelLoggedIn');
if (!this.jobModel) {
this.jobModel = new JobModel();
}
this.ratingModel = navParams.get('ratingModel');
}
presentFilterMap(event: Event) {
//this.viewCtrl.dismiss().then(() => {
this.nav.push(MapPage, {
jobModel: this.jobModel,
ratingModel: this.ratingModel,
fromSearch: true
});
//});
}
presentFilterCategories(event: Event) {
this.viewCtrl.dismiss().then(() => {
this.nav.push(CategoryPage, {
jobModel: this.jobModel,
ratingModel: this.ratingModel,
fromSearch: true
});
});
}
presentFilterRating(event: Event) {
//this.viewCtrl.dismiss().then(() => {
this.nav.push(ReviewPage, {
jobModel: this.jobModel,
ratingModel: this.ratingModel,
personModelLoggedIn: this.personModelLoggedIn,
fromFilter: true
});
//});
}
presentFilterTime(event: Event) {
this.viewCtrl.dismiss().then(() => {
this.nav.push(DateTimePage, {
lastOnline: this.lastOnline,
fromSearch: true
});
});
}
clearFilters() {
if (this.jobModel) {
this.jobModel.locations = [];
this.jobModel.categories = [];
this.jobModel.subCategories = [];
this.lastOnline = null;
}
if (this.ratingModel) {
this.ratingModel.rating = -1;
}
let data = {
jobModel: this.jobModel,
ratingModel: this.ratingModel,
fromClearFilters: true
};
this.nav.popToRoot().then(() => {
this.events.publish('popupFilter:update', data);
});
}
}
Error
The popover is not displayed, but the following error is displayed in the browser console:
PopoverCmp ionViewPreLoad error: No component factory found for SearchJobsPopOverPage
Any help appreciated.
Sill me, I forgot to define the page in app.module.ts as is required post rc0.

Ionic2 Upgrade from beta to rc3: App.html”: Error: ENOENT: no such file or directory

I am in the process of upgrading from Ionic 2 beta to Ionic 2 rc3.
I have my app.component.ts file, that worked fine, when it was just displaying a root page. But as soon as I have tried to add menu items from my old working Ionic 2 beta version, I get the error below.
If anyone can advise how I can resolve this, I would appreciate the help.
Compile Error in CLI
[13:14:56] template error, "E:\Development\IDE\ionic-apps\WhatsAppClone\src\app\build\app.html": Error: ENOENT: no such
file or directory, open 'E:\Development\IDE\ionic-apps\WhatsAppClone\src\app\build\app.html'
Runtime Error in browser console
Unhandled Promise rejection: Failed to load build/app.html ; Zone: meteor-rxjs-zone ; Task: Promise.then ; Value: Failed to load build/app.html undefined polyfills.js:3:7730
Error: Uncaught (in promise): Failed to load build/app.html
Stack trace:
s#http://localhost:8100/build/polyfills.js:3:8568
s#http://localhost:8100/build/polyfills.js:3:8391
h/<#http://localhost:8100/build/polyfills.js:3:8902
sg</d</t.prototype.invokeTask#http://localhost:8100/build/polyfills.js:3:14040
sg</v</e.prototype.runTask#http://localhost:8100/build/polyfills.js:3:11392
i#http://localhost:8100/build/polyfills.js:3:8021
t/this.invoke#http://localhost:8100/build/polyfills.js:3:15204
app.component.ts
import { Component, ViewChild } from '#angular/core';
import { Storage } from "#ionic/storage";
import { Platform, Events, AlertController, Nav } from 'ionic-angular';
import { StatusBar, Push, Splashscreen } from 'ionic-native';
import { SearchJobsPage } from "../pages/searchjobs/searchjobs";
import { LoginPage } from '../pages/login/login';
import { LogoutPage } from '../pages/logout/logout';
import { PersonModel } from '../pages/model/personModel';
import { ChatsPage } from '../pages/chats/chats';
import { PersonPage } from '../pages/person/person';
import { SearchFavouriteJobsPage } from '../pages/searchfavouritejobs/searchfavouritejobs';
import { SearchPostingsPage } from '../pages/searchpostings/searchpostings';
import { SearchFavouritePostingsPage } from '../pages/searchfavouritepostings/searchfavouritepostings';
import { UtilityService } from '../pages/utils/utilityService';
import { NotificationService } from '../pages/service/notificationService';
import { JobService } from '../pages/service/jobService';
import { JobModel } from '../pages/model/jobModel';
import { MapLocationsPage } from '../pages/maplocations/maplocations';
import { MapRangePage } from '../pages/maprange/maprange';
//import { METEOR_PROVIDERS } from 'angular2-meteor';
// import * as Check from 'meteor/check';
// import * as EJSON from 'meteor/ejson';
//declare let Meteor;
#Component({
templateUrl: 'build/app.html'
})
export class MyApp {
#ViewChild(Nav) nav: Nav;
rootPage: any;
public storage: Storage = null;
public pages: Array<{ title: string, component: any }>;
public pages_person: Array<{ title: string, component: any }>;
public pages_person_admin: Array<{ title: string, component: any }>;
public menuTitle: string = 'Menu';
public personModel: PersonModel = null;
public utilityService: UtilityService = null;
public notificationService: NotificationService = null;
public personModelLoggedIn: PersonModel;
public jobService: JobService = null;
public events: Events = null;
public ios: boolean = false;
constructor(private platform: Platform, utilityService: UtilityService, notificationService: NotificationService, jobService: JobService, events: Events, private alertCtrl: AlertController, storage: Storage) {
this.storage = storage;
this.utilityService = utilityService;
this.jobService = jobService;
this.notificationService = notificationService;
this.events = events;
this.initializeApp();
if (this.platform.is('ios')) {
this.ios = true;
}
// this.rootPage = Meteor.user() ? TabsPage : LoginComponent;
this.rootPage = SearchJobsPage;
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.initializeApp();
StatusBar.styleDefault();
Splashscreen.hide();
});
// used for an example of ngFor and navigation
this.pages = [
{ title: 'Market', component: SearchJobsPage },
{ title: 'Postings', component: SearchPostingsPage },
{ title: 'Login', component: LoginPage }
];
this.pages_person = [
{ title: 'Market', component: SearchJobsPage },
{ title: 'Market Favourites', component: SearchFavouriteJobsPage },
{ title: 'Postings', component: SearchPostingsPage },
{ title: 'Favourite Postings', component: SearchFavouritePostingsPage },
{ title: 'Messages', component: ChatsPage },
{ title: 'Profile', component: PersonPage },
{ title: 'Logout', component: LogoutPage }
];
this.pages_person_admin = [
{ title: 'Market', component: SearchJobsPage },
{ title: 'Market Favourites', component: SearchFavouriteJobsPage },
{ title: 'Postings', component: SearchPostingsPage },
{ title: 'Favourite Postings', component: SearchFavouritePostingsPage },
{ title: 'Messages', component: ChatsPage },
{ title: 'Profile', component: PersonPage },
{ title: 'Logout', component: LogoutPage },
{ title: 'Map Locations', component: MapLocationsPage },
{ title: 'Map Range', component: MapRangePage }
];
}
initializeApp() {
StatusBar.styleDefault();
this.checkLogin();
this.utilityService.startUpChecks();
if (window['cordova']) {
this.utilityService.setLocalStrorage('this.chats.observe', 'false');
this.utilityService.setLocalStrorage('this.messages.observe', 'false');
this.utilityService.setLocalStrorage('this.messages.subscribe', 'false');
this.utilityService.setLocalStrorage('push:notifications.subscribe', 'false');
}
this.subscribeEvents();
}
// openPage(page) {
// // Reset the content nav to have just this page
// // we wouldn't want the back button to show in this scenario
// this.nav.setRoot(page.component);
// }
public subscribeEvents(): void {
this.events.subscribe('push:notifications', (data) => {
this.checkLogin();
});
}
public pushNotifications(): void {
let observedPromise: Promise<string> = this.utilityService.getLocalStrorage('push:notifications.subscribe');
observedPromise.then((observed: string) => {
if (!observed || observed != 'true') {
this.utilityService.setLocalStrorage('push:notifications.subscribe', 'true');
try {
if (window['cordova']) {
if (this.personModelLoggedIn) {
let promiseJobsForPerson: Promise<JobModel[]> = this.jobService.getJobsByPerson(this.personModelLoggedIn.id);
promiseJobsForPerson.then((data) => {
let jobModelsForPerson: JobModel[] = data;
let topics: string[] = [];
topics.push('P' + this.personModelLoggedIn.id);
for (let i = 0; i < jobModelsForPerson.length; i++) {
let jobModel: JobModel = jobModelsForPerson[i];
topics.push('J' + jobModel.id);
}
//topics.push('J65'); // deleteme
//topics.push('P9'); // deleteme
let push = Push.init({
android: {
senderID: "893141127008",
topics: topics
},
ios: {
alert: "true",
badge: false,
sound: "true",
topics: topics
},
windows: {}
});
push.on('registration', (data1) => {
this.events.subscribe('messages:notify', (data) => {
let promise: Promise<string> = this.notificationService.push('null', data[0].topic, data[0].message, data[0].title);
promise.then((data2) => {
// console.log('app.ts messages2:notify', data2);
});
});
});
push.on('notification', (data) => {
this.events.publish('messages:update');
if (this.nav.getActive().name != 'ChatsPage' && this.nav.getActive().name != 'MessagesPage') {
//if user using app and push notification comes
if (data.additionalData.foreground) {
//if application open, show popup
let confirmAlert = this.alertCtrl.create({
title: data.title,
message: data.message,
buttons: [{
text: 'Ignore',
role: 'cancel'
}, {
text: 'View',
handler: () => {
this.rootPage = ChatsPage;
}
}]
});
confirmAlert.present(confirmAlert);
} else {
this.rootPage = ChatsPage;
}
}
});
push.on('error', (e) => {
alert('Error: ' + e.message);
console.log(e);
});
});
}
}
} catch (e) {
alert('Push Notification: ' + e.message());
console.log('Push Notification: ' + e.message());
}
}
});
}
public checkLogin(): void {
let promise: Promise<string> = this.utilityService.getLoggedInPerson();
promise.then((data) => {
this.personModelLoggedIn = JSON.parse(data);
if (this.personModelLoggedIn) {
this.utilityService.setUpMenuItems();
this.pushNotifications();
}
});
}
}
app.html
<ion-menu [content]="content" id="unauthenticated">
<ion-toolbar>
<ion-title>Menu</ion-title>
</ion-toolbar>
<ion-content>
<ion-list>
<button menuClose ion-item *ngFor="let p of pages" (click)="openPage(p)">
{{p.title}}
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-menu [content]="content" id="authenticated-person">
<ion-toolbar [class]="ios ? 'menu-toolbar' : ''">
<ion-title [class]="ios ? 'menu-title' : ''">
<div class="item-avatar-img" id="menu-item-avatar-img-person"></div>
<div class="item-avatar-name" id="menu-item-avatar-name-person"></div>
</ion-title>
</ion-toolbar>
<ion-content>
<ion-list>
<button menuClose ion-item *ngFor="let p of pages_person" (click)="openPage(p)">
{{p.title}}
</button>
</ion-list>
</ion-content>
</ion-menu>
<ion-menu [content]="content" id="authenticated-person-admin">
<ion-toolbar [class]="ios ? 'menu-toolbar' : ''">
<ion-title [class]="ios ? 'menu-title' : ''">
<div class="item-avatar-img" id="menu-item-avatar-img-person-admin"></div>
<div class="item-avatar-name" id="menu-item-avatar-name-person-admin"></div>
</ion-title>
</ion-toolbar>
<ion-content>
<ion-list>
<button menuClose ion-item *ngFor="let p of pages_person_admin" (click)="openPage(p)">
{{p.title}}
</button>
</ion-list>
</ion-content>
</ion-menu>
<!-- Disable swipe-to-go-back because it's poor UX to combine STGB with side menus -->
<ion-nav [root]="rootPage" #content swipeBackEnabled="false"></ion-nav>
Directory
You have set your templateUrl as build/app.html.
You shouldnt check it in build folder.
Try templateUrl: 'app.html' in app.component.ts

How to search title of the elements in navigation using searchbar in scriptionic-v2 typescript

I want to search the title of the elements in the navigation using the searchbar.
I want to add a search function in the following code.
import { Component } from '#angular/core';
import { NavController, NavParams } from 'ionic-angular';
#Component({
selector: 'page-emergency',
templateUrl: 'emergency.html'
})
#Component({
templateUrl: 'emergency_details.html',
})
export class EmergencyDetailsPage {
item;
constructor(params: NavParams) {
this.item = params.data.item;
}
}
#Component({
template: `
<ion-header>
<ion-navbar>
<ion-title>응급</ion-title>
<ion-searchbar (ionInput)="getItems($event)"></ion-searchbar>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<button ion-item *ngFor="let item of items" (click)="openNavDetailsPage(item)" icon-left>
<ion-icon [name]="'logo-' + item.icon" [ngStyle]="{'color': item.color}" item-left></ion-icon>
{{ item.title }}
</button>
</ion-list>
</ion-content>
`
})
export class EmergencyPage {
items;
constructor(public nav: NavController) {
this.items = [
{
'title': 'Angular',
'icon': 'angular',
'description': 'A powerful Javascript framework for building single page apps. Angular is open source, and maintained by Google.',
'color': '#E63135'
},
{
'title': 'CSS3',
'icon': 'css3',
'description': 'The latest version of cascading stylesheets - the styling language of the web!',
'color': '#0CA9EA'
}
]
}
openNavDetailsPage(item) {
this.nav.push(EmergencyDetailsPage, { item: item });
}
}
html
<ion-searchbar (ionInput)="getItems($event)" ></ion-searchbar>
<ion-list >
<ion-item *ngFor="let item of items " (click)="openNavDetailsPage(item)">
{{ item.title }}
</ion-item>
</ion-list>
tsfile
openNavDetailsPage(item) {
this.nav.push(EmergencyDetailsPage, item);
}