$ionicPopup.alert is not a function error!

#1

Ionic popup not working…

<button class = "button" ng-click = "showAlert()">Add Popup Show</button>    

$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');
   });
 };
#2

have you injected $ionicPopup in your controller?

#4

Yes, I have!

.controller('ListController', ['$scope', '$http', '$state','$window', '$ionicActionSheet', '$timeout','$ionicPopup', 'updateDbService',function($scope, $http, $state, $window, $ionicActionSheet,$ionicPopup, $timeout,updateDbService) {
#5

ah …

you switched the $timeout and $ionicPopup :slight_smile:

'$timeout','$ionicPopup'

and

$ionicPopup, $timeout

2 Likes
#6

Thank you so much! Sorry I just realised I never posted it! Also, why?

#7

haha … I had the same “problem” once … kept me debugging almost a hour untill I figured it out

#8

I might receive some hate for this…

But when you don’t minify your code, you dont really need to explicitly name your injections.

#9

Thank you so much for posting this. I assumed Ionic didn’t care what order the injected parameters were in because of seeing examples where they were out of order but you helped me fix a bug I’ve spent almost a week trying to fix with this!