# Ionic alertbox issue

**URL:** <https://forum.ionicframework.com/t/ionic-alertbox-issue/2165>\
**Category:** ionic-v1\
**Created:** [March 24, 2014, 6:46am UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165 "2014-03-24T06:46:49Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![nik](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nik](https://forum.ionicframework.com/u/nik)\
**Post date:** [March 24, 2014, 6:46am UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/1 "2014-03-24T06:46:50Z")

</div>

i m trying to create alert box on button click with OK button,

> $scope.showAlert = function() {  
> $ionicPopup.alert({  
> title: ‘Success!’,  
> content: ‘Hello World!!!’  
> }).then(function(res) {  
> console.log(‘Test Alert Box’);  
> });  
> };

but in console i m getting error

> Uncaught ReferenceError: $ionicPopup is not defined

---

<div class="post-metadata">

**Author:** ![maleeb](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/maleeb/32/140228_2.png) [@maleeb](https://forum.ionicframework.com/u/maleeb)\
**Post date:** [March 24, 2014, 8:23am UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/2 "2014-03-24T08:23:52Z")

</div>

u must define it in the controller function

```
function($scope, $ionicPopup) {
```

---

<div class="post-metadata">

**Author:** ![nik](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nik](https://forum.ionicframework.com/u/nik)\
**Post date:** [March 24, 2014, 9:14am UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/3 "2014-03-24T09:14:00Z")

</div>

@maleeb : Thanks for the reply, i added $ionicPopup in my controller function but now i m getting another error

> Error: [$injector:unpr] Unknown provider: TemplateLoaderProvider ← TemplateLoader ← $ionicPopup

---

<div class="post-metadata">

**Author:** ![Calendee](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/calendee/32/13656_2.png) [@Calendee](https://forum.ionicframework.com/u/Calendee)\
**Post date:** [March 24, 2014, 2:04pm UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/4 "2014-03-24T14:04:30Z")

</div>

Have you tried reviewing the demo code:

https://codepen.io/ionic/embed/preview/zkmhJ?height=300&slug-hash=zkmhJ&default-tabs=js,result&host=https://codepen.io

If that doesn’t help. it will be easier for us to help if you put up a CodePen sample.

---

<div class="post-metadata">

**Author:** ![nik](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nik](https://forum.ionicframework.com/u/nik)\
**Post date:** [March 25, 2014, 7:52am UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/5 "2014-03-25T07:52:55Z")

</div>

@Calendee: Thanks for the reply, yeah i referred same example but in this the included js and css is different so this same example ll not work for me as i m using separate js for all.but in this example they created bundle of some js like…

> ionic.bundle.js is a concatenation of:  
> ionic.js, angular.js, angular-animate.js,  
> angular-ui-router.js, and ionic-angular.js

---

<div class="post-metadata">

**Author:** ![patrickdu](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@patrickdu](https://forum.ionicframework.com/u/patrickdu)\
**Post date:** [April 30, 2014, 12:21pm UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/6 "2014-04-30T12:21:16Z")

</div>

@nik have you found a solution for that?

---

<div class="post-metadata">

**Author:** ![Calendee](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/calendee/32/13656_2.png) [@Calendee](https://forum.ionicframework.com/u/Calendee)\
**Post date:** [May 1, 2014, 8:25pm UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/7 "2014-05-01T20:25:35Z")

</div>

You can manually include all the JS libraries required:

```auto
    <script src="/js/ionic/ionic.js"></script>
    <script src="/js/angular/angular.min.js"></script>
    <script src="/js/angular/angular-animate.min.js"></script>
    <script src="/js/angular/angular-sanitize.min.js"></script>
    <script src="/js/lib/angular-ui-router.min.js"></script>
    <script src="/js/ionic/ionic-angular.js"></script>

```

---

<div class="post-metadata">

**Author:** ![patrickdu](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@patrickdu](https://forum.ionicframework.com/u/patrickdu)\
**Post date:** [May 2, 2014, 11:53am UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/8 "2014-05-02T11:53:00Z")

</div>

There seams also to be a bug in ionic-angular.j Line 539. There should not be a dependency to TemplateLoader because it doesn’t exist. Should i maybe be ionicTemplateLoader?

This will fix this error:

```
Error: [$injector:unpr] Unknown provider: TemplateLoaderProvider <- TemplateLoader <- $ionicPopup
```

---

<div class="post-metadata">

**Author:** ![Calendee](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/calendee/32/13656_2.png) [@Calendee](https://forum.ionicframework.com/u/Calendee)\
**Post date:** [May 2, 2014, 12:12pm UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/9 "2014-05-02T12:12:02Z")

</div>

You mind opening a new thread and showing an CodePen sample of how you are getting this error?

---

<div class="post-metadata">

**Author:** ![voliva](https://avatars.discourse-cdn.com/v4/letter/v/a6a055/32.png) [@voliva](https://forum.ionicframework.com/u/voliva)\
**Post date:** [May 19, 2014, 9:39am UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/10 "2014-05-19T09:39:34Z")

</div>

I just recreated the “unkown provider TemplateLoader” issue. The thing is that for me it’s really hard to create a CodePen, since for some reason it only happens if I lazy-load my app ([https://github.com/ocombe/ocLazyLoad](https://github.com/ocombe/ocLazyLoad)). The ionic bundle script is “hard-coded” into index.html in both cases.

patrickdu solved it for me. Replacing `'TemplateLoader'` for `'$ionicTemplateLoader'` in:

```
angular.module('ionic.service.popup', ['ionic.service.templateLoad'])
.factory('$ionicPopup', ['$rootScope', '$document', '$compile', 'TemplateLoader', function($rootScope, $document, $compile, TemplateLoader) {

```

to

```
angular.module('ionic.service.popup', ['ionic.service.templateLoad'])
.factory('$ionicPopup', ['$rootScope', '$document', '$compile', '$ionicTemplateLoader', function($rootScope, $document, $compile, TemplateLoader) {

```

Fixes the issue.

edit: I just updated ionic to 1.0.0-beta.4 and it’s fixed, no need to “fix” that line.

---

<div class="post-metadata">

**Author:** ![ragethunder](https://avatars.discourse-cdn.com/v4/letter/r/74df32/32.png) [@ragethunder](https://forum.ionicframework.com/u/ragethunder)\
**Post date:** [August 11, 2014, 4:01pm UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/11 "2014-08-11T16:01:07Z")

</div>

I’m still having the same issue here:

```
angular.module('ionicApp', ['ionic'])
.config(function($stateProvider, $urlRouterProvider) { state provider and url route provider... }
.controller('SignInCtrl', function($scope, $state, $ionicPopup) { some code to display popups... }

```

But this way I’m getting: Error: [$injector:unpr] [http://errors.angularjs.org/1.2.12/$injector/unpr?p0=TemplateLoaderProvider%20\<-%20TemplateLoader%20\<-%20%24ionicPopup](http://errors.angularjs.org/1.2.12/%24injector/unpr?p0=TemplateLoaderProvider%20%3C-%20TemplateLoader%20%3C-%20%24ionicPopup)

And if I remove $ionicPopup from definition of the functions I’m getting that it’s undefined.

I’m using ionic.bundle.min.js picked up from your official github repo. What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![mt\_\_](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@mt\_\_](https://forum.ionicframework.com/u/mt__)\
**Post date:** [July 19, 2015, 4:52pm UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/12 "2015-07-19T16:52:00Z")

</div>

I was having the same problem(s) until I declared dependencies for that controller, e.g.:

```
.controller('FormCtrl', ['$scope','$ionicPopup', function ($scope, $ionicPopup) {

```

That fixed any problems I had with the pop-up!

---

<div class="post-metadata">

**Author:** ![anisha\_s](https://avatars.discourse-cdn.com/v4/letter/a/3ab097/32.png) [@anisha\_s](https://forum.ionicframework.com/u/anisha_s)\
**Post date:** [September 15, 2016, 7:25am UTC](https://forum.ionicframework.com/t/ionic-alertbox-issue/2165/13 "2016-09-15T07:25:39Z")

</div>

> **[alert](https://codepen.io/ashnaanu/pen/LRNQWB)**
>
> ...

  
the alert not displayed y?  
if change this line var app = angular.module(“myApp”, [“ngRoute”]); into var app = angular.module(“myApp”, [“ionic”]);,alert displayed  
but i want ngRoute also.please help
