Is there any way to change alert direction in ionic 2 ?
const alert = this.alertCtrl.create({
title: 'خطأ',
subTitle: 'GPS والوصول إلى الشبكة غير ممكن.',
enableBackdropDismiss: false,
buttons: [{
text: 'نعم',
handler: () => {
setTimeout(() => this.locate(), 1500);
}
}],
});
I tried and tested some css but fails.
I try but have a difficult way for change this.
Try use ionic AlertController
And set enableBackdropDismiss:false for work like alertCtrl
Related
I migrated from Ionic 4 to Ionic 5 and noticed my toastControllers are not showing the "close" button even if I set up the ToastOptions properties with showCloseButton: true
I fixed it adding explicitly the buttons array like this:
let toast = this.toastCtrl.create({
message: 'User was added successfully',
showCloseButton: true,
position: 'top',
buttons: [
{
text: "close",
handler: () => {
console.log('Close clicked');
}
}
]
});
After a lot of try and error, trying to find a solution to this, I understood thanks to help of Eddy Verbruggen that there two unique way to add markers to mapbox map: by code inside of onMapReady() or programmatically.
But now, I find something that I can not solve: using exactly code indicated Declaring a map programmatically, when run the app appears errors originated in "TypeError: mapbox.show is not a function".
The code is:
`var mapbox = require("nativescript-mapbox");
var platform = require("platform");
var isIOS = platform.device.os === platform.platformNames.ios;
mapbox.show({
accessToken: 'here i wrote my own API ACCESS TOKEN',
style: street,
margins: {
left: 40, // default 0
right: 40, // default 0
top: 450, // default 0
bottom: isIOS ? 50: 0
},
center: { // optional without a default
lat: 52.3702160,
lng: 4.8951680
},
zoomLevel: 9.25,
showUserLocation: true,
hideAttribution: false,
hideLogo: false,
hideCompass: false,
disableRotation: false,
disableScroll: false,
disableZoom: false,
markers: [
{
id: 1,
lat: 52.3732160,
lng: 4.8941680,
title: 'Nice location',
subtitle: 'Really really nice location',
icon: 'res://cool_marker',
selected: true,
onTap: function(marker) { console.log("This marker was tapped"); },
onCalloutTap: function(marker) { console.log("marker was tapped"); }
}
]
}).then(
function(showResult) {
console.log("Mapbox show done for " + (showResult.ios ? "iOS" :
"Android") + ", native object received: " + (showResult.ios ?
showResult.ios : showResult.android));
},
function(error) {
console.log("mapbox show error: " + error);
}
)`
To clarify, the app is build from "tns create my-app-name --template tns-template-blank". I only added nativescript-mapbox plugin and insert code indicate in "Declaring a map programmatically" inside on home.js file.
I can't understand why appear that error, I'm sure that plugin was correctly installed. The app uses NS version 3.4.1 and nativescript-mapbox version 3.3.0, on Android.
I have this code in my application:
$ionicPopup.alert({
title: $scope.header1,
template: 'The was a problem connecting to the server. Please check your internet connection and try again.'
});
ionic.Platform.exitApp()
what I have noticed is that in Android, the application exits quickly without showing the pop up message. What I wanted to do is execute
ionic.Platform.exitApp()
after the user press the 'Ok' button in the pop-up. ls there something like an "onleave" event in ionic Popup?
The best approach may be to define your own 'OK' button as opposed to leveraging the default dismiss one - that way you can invoke ionic.Platform.exitApp() upon the user clicking/tapping your button.
Example:
import { AlertController } from 'ionic-angular';
constructor(private alertCtrl: AlertController) {
}
presentAlert() {
let alert = this.alertCtrl.create({
title: YourCustomHeader,
//subTitle: 'optional text',
message: 'The was a problem connecting to the server. Please check your internet connection and try again.',
buttons: [
{
text: 'OK',
handler: () => {
ionic.Platform.exitApp();
}
}
]
});
alert.present();
}
Reference: https://ionicframework.com/docs/api/components/alert/AlertController/#usage
I am creating an ionic 2 application for android and ios. I have an alert controller that prompts the user for a text input, however when the alert pops up I would like the keyboard to focus on the input, and for the placeholder text to be highlighted. Currently you must tap on the text input for the keyboard to pop up. Is this possible to implement?
here is my alert controller code:
let prompt = this.alertCtrl.create({
title: this.name,
message: this.nameMessage,
inputs: [
{
name: 'name',
placeholder: this.name
},
],
buttons: [
{
text: this.save,
handler: data => {
resolve(data.name);
}
}
],
enableBackdropDismiss: false
});
prompt.present();
This is my solution.
First
inputs: [
{
id: "autofocu",
......
}
],
And then
alert.present()
.then(() => {
document.getElementById('autofocu').focus();
})
.catch()
Please help someone, below code opening page but not firing event
this._browser = this.inAppBrowser.create('http://www.google.com');
this._browser.on('loadstart').subscribe((event) => {
let alert1 = this._alertCtrl.create({
subTitle: 'load start',
buttons: ['ok!']
});
alert1.present();
});