Hi! I am using Ionic 2 to create a demo app so I start learning about this product
I’m integrating it with MobileFirst Platform from IBM to use adapters and some other features. But I think my issue is related on how to use some Ionic components.
Basically, I have a service injected to my page.ts that retrieves some objects from a NoSQL database.
Using ion-list I was able to list all of them succesfully, but now I want to enhance that functionality making those items clickable in order to show an alert with further information obtained from that object that’s already filling the list item.
Here’s my HTML:
<ion-navbar *navbar secondary>
<ion-title>La agenda de hoy</ion-title>
</ion-navbar>
<ion-content>
<ion-list>
<ion-item *ngFor="let item of delivery" (click)="displayDetails(item)">
<h3>{{item.talk}}</h3>
<p>Disertante: {{item.name}}</p>
</ion-item>
</ion-list>
</ion-content>
And this is my page.ts
import {Page, Alert} from 'ionic-angular';
import {NavController} from "ionic-angular/index";
import {ScheduleService} from '../../providers/schedule-service/schedule-service'
@Page({
templateUrl: 'build/pages/agenda/agenda.html'
})
export class SchedulePage {
schedule: any;
delivery: any;
times: any;
nav: any;
constructor(schedule: ScheduleService, nav: NavController) {
console.log('---> Agenda: Page Initialized');
this.schedule = schedule;
this.loadSchedule();
}
loadSchedule(){
this.schedule.load().then((results) => {
let tm = [];
for(var i=0; i < results.length; i++){
if (tm.indexOf(results[i].time) == -1) tm.push(results[i].time);
}
console.log('---> times array', tm);
this.times = tm;
this.delivery = results;
})
}
displayDetails(item){
console.log('---> Clicked on talk: '+item.talk);
let endTime = parseInt(item.time);
endTime++;
let msg = 'Disertante: '+item.name+'<br>Hora de inicio: '+item.time+':00<br>Hora de Finalizacion: '+endTime+':00<br>'
let prompt = Alert.create({
title: 'Detalles de la charla',
subTitle: item.talk,
message: msg,
buttons: [
{
text: 'Cerrar'
}
]
});
this.nav.present(prompt);
}
}
The final result shows the typical list but everytime I click the items no alert is being shown, and, in fact, I am getting no log event, so I am guessing this is definitely not working.
Is there something wrong with my code? I am using Ionic 2.0.0-beta.26
Thanks in advance!