I create a very simple code for call a number after confirm on an alert popup.
After confirm the call doesn’t start
This is my code for .html
<ion-item *ngFor="let item of emergencylist" (click)="emergencyCall(item)">
<ion-row class="center">
<ion-col width-80>
<img src="assets/img/buttons/{{item.id}}.png">
</ion-col>
<ion-col width-20 class="icon-call">
<ion-icon name="call"></ion-icon>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<p>{{item.desc}}</p>
</ion-col>
</ion-row>
</ion-item>
This is code for .ts
this.emergencylist = [
{ 'id': 'police', 'name': 'Police', 'number': '+39112', 'desc': 'National helpline for all emergencies, to report robbaries, thefts or assaults, accidents ecc.' },
{ 'id': 'carabinieri', 'name': 'Carabinieri', 'number': '+39113', 'desc': 'Dial this number to access Carabinieri police headquarters. Foreign language response service available' },
{ 'id': 'firebridage', 'name': 'Fire Bridage', 'number': '+39115', 'desc': 'In the event of fire, smoke or gas leaks, you can make a direct call to this number' },
{ 'id': 'healthcare', 'name': 'Healthcare', 'number': '+39118', 'desc': 'Healthcare / Ambulance network for transport to the closest hospital or health facility' },
{ 'id': 'roadassistance', 'name': 'Road Assistance', 'number': '+39803116', 'desc': 'Number to dial for roadside assistance, if your engine breaks down or in the event of another problem with your car' },
{ 'id': 'forestrycorps', 'name': 'Forestry Corps', 'number': '+391515', 'desc': 'Environmental emergencies, especially forest fires' },
{ 'id': 'coastguard', 'name': 'Coast Guard', 'number': '+391530', 'desc': 'Helpline for emergency situations in Italian waters' }
]
emergencyCall(item) {
console.log(item.number);
let alert = this.alertCtrl.create({
title: 'Are you sure?',
message: 'Do you want to call the ' + item.name + ': ' + item.number,
buttons: [
{
text: 'Cancel',
role: 'cancel',
handler: () => {
}
},
{
text: 'Call',
handler: () => {
console.log(item.number);
let browser = new InAppBrowser('tel://' + item.number, "_blank", "EnableViewPortScale=yes");
browser.show();
}
}
]
});
alert.present();
}