# Alert popup have errors

**URL:** <https://forum.ionicframework.com/t/alert-popup-have-errors/84464>\
**Category:** ionic-v1\
**Created:** [March 28, 2017, 6:02am UTC](https://forum.ionicframework.com/t/alert-popup-have-errors/84464 "2017-03-28T06:02:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![akramzaki](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/akramzaki/32/107936_2.png) [@akramzaki](https://forum.ionicframework.com/u/akramzaki)\
**Post date:** [March 28, 2017, 6:02am UTC](https://forum.ionicframework.com/t/alert-popup-have-errors/84464/1 "2017-03-28T06:02:26Z")

</div>

I’m having issue with $ionicPopup. It gives me error  
ionic.bundle.js:26799 TypeError: Cannot read property ‘alert’ of undefined  
at controllers.js:44  
at processQueue (ionic.bundle.js:29132)  
at ionic.bundle.js:29148  
at Scope.$eval (ionic.bundle.js:30400)  
at Scope.$digest (ionic.bundle.js:30216)  
at Scope.$apply (ionic.bundle.js:30508)  
at done (ionic.bundle.js:24829)  
at completeRequest (ionic.bundle.js:25027)  
at XMLHttpRequest.requestLoaded (ionic.bundle.js:24968)

this is my code  
.controller(‘loginCtrl’, [’$scope’, ‘ionicToast’, ‘AuthService’, function($scope, $stateParams, AuthService,$location, $rootScope,$state,$ionicLoading, $ionicPopup) {

$scope.user = {  
data : {  
email: “”,  
password: “”  
}  
};

$scope.userLogin = function() {  
if($scope.user.data.email !== “” && $scope.user.data.password !== “” ){  
//$ionicLoading.show();  
AuthService.login($scope.user.data).then(function(msg) {  
$rootScope.AuthCheck = AuthService.isAutheticate();  
$state.go(‘app.dashboard’);  
},function(errMsg) {  
var alertPopup = $ionicPopup.alert({  
title: ‘Invalid Email / Password’,  
template: errMsg  
});  
});  
//.finally(function() {  
// $ionicLoading.hide();  
//});  
};

};  
}])

before this it gave me .show is not defined and then this problem. How to solve it?

---

<div class="post-metadata">

**Author:** ![Adonai](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/adonai/32/71684_2.png) [@Adonai](https://forum.ionicframework.com/u/Adonai)\
**Post date:** [March 28, 2017, 7:00am UTC](https://forum.ionicframework.com/t/alert-popup-have-errors/84464/2 "2017-03-28T07:00:47Z")

</div>

Hi!

The problem is in your controller function. When you use the brackets notation, all your brackets parameters must be the same that your last function parameter

Example:

```
.controller(["a", "b", "c", "d", function(a, b, c, d){}])

```

You can not do this:

```
.controller(["a", "b", "c", "d", function(a, b){}])

```

because _c_ and _d_ would be `undefined`.

Your solution is change your `controller` function to:

```
.controller('loginCtrl', ['$scope', 'stateParams', 'AuthService', '$location', '$rootScope', '$state', '$ionicLoading', '$ionicPopup', 
function($scope, $stateParams, AuthService,$location, $rootScope,$state,$ionicLoading, $ionicPopup)

```

That should work.

---

<div class="post-metadata">

**Author:** ![akramzaki](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/akramzaki/32/107936_2.png) [@akramzaki](https://forum.ionicframework.com/u/akramzaki)\
**Post date:** [March 28, 2017, 9:23am UTC](https://forum.ionicframework.com/t/alert-popup-have-errors/84464/3 "2017-03-28T09:23:52Z")

</div>

It works now. Thank you!
