Sto implementando un'applicazione usando ionico v1, sto creando un'utilità .js
file per separare alcune funzioni che verranno utilizzate solo nell'ambiente di sviluppo. Sto cercando di implementare una funzione a cui è possibile accedere da qualsiasi vista ionica. Il codice che sto utilizzando è:
myApp.prototype.showAlert = function() {
var alertPopup = $ionicPopup.alert({
title: "Gendalf",
template: "You shall not Pass"
});
};
risposte:
1 per risposta № 1Dai documenti ionici Qui
// An alert dialog
$scope.showAlert = function() {
var alertPopup = $ionicPopup.alert({
title: "Don"t eat that!",
template: "It might taste good"
});
alertPopup.then(function(res) {
console.log("Thank you for not eating my delicious ice cream cone");
});
};
Poi, quando si vuole mostrare che basta chiamare il metodo:
$scope.showAlert();
Nel tuo codice di esempio lo chiameresti come:
myApp.showAlert();