Hi,
If I am biding a click event to an element which is under a if condition in DOM, the events associated with same element are not getting triggered in Android devices, same thing works fine in iOS devices. I have a created a sample git repo to reproduce the same. Please check the home.htm
l and home.ts
for the code.
sample code :
home.html
<ion-searchbar placeholder="Search" [(ngModel)]="myInput" (ionInput)="search($event)" (ionBlur)="onBlur($event)" (ionCancel)="onCancel($event)"> </ion-searchbar>
<ion-list *ngIf="!isSearchOn">
<ion-item *ngFor="let emp of selectedEmployees">
<p>{{emp}}</p>
</ion-item>
</ion-list>
<ion-list *ngIf="isSearchOn">
<ion-item *ngFor="let emp of employees" tappable (click)="itemTapped($event, emp)">
<p>{{emp}}</p>
</ion-item>
</ion-list>
home.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
public selectedEmployees: any = [];
public employees: any = [];
public isSearchOn: any = false;
public myInput:any ="";
constructor(public navCtrl: NavController) {
this.selectedEmployees = [];
this.employees = ["dummy","care","me","try","we"];
}
search(event) {
let q = this.myInput;
if (q.trim() == '') {
this.isSearchOn = false;
return;
}
this.isSearchOn = true;
}
onCancel(event) {
this.isSearchOn = false;
}
onBlur(event) {
this.myInput = "";
this.isSearchOn = false;
}
itemTapped(event, employee) {
debugger
this.selectedEmployees.push(employee);
this.isSearchOn = false;
console.log(employee);
}
}
itemTapped event is never getting called!
Sorry if its confusing!
GIT LINK