# Bug: Modal iOS and Web

**URL:** <https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518>\
**Category:** ionic-v1\
**Created:** [May 20, 2014, 9:28am UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518 "2014-05-20T09:28:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![lailo](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lailo](https://forum.ionicframework.com/u/lailo)\
**Post date:** [May 20, 2014, 9:28am UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/1 "2014-05-20T09:28:50Z")

</div>

Hi guys,

I have a problem with the modal view.  
I am doing it like it is shown in [http://ionicframework.com/docs/api/service/$ionicModal/](http://ionicframework.com/docs/api/service/%24ionicModal/).

The problem is, that the modal does not apear on the browser and on the ios i get an error that the template was not found.

What can i do ?

My Controller:

```
'use strict';
angular.module('myapp.controllers')

.controller('ModalController', function($scope, $ionicModal) {

  $ionicModal.fromTemplateUrl('../templates/modal.content.html', {
    scope: $scope,
    animation: 'slide-in-up'
  }).then(function(modal) {
    $scope.modal = modal;
  });
  $scope.openModal = function() {
    $scope.modal.show();
  };
  $scope.closeModal = function() {
    $scope.modal.hide();
  };
  //Cleanup the modal when we're done with it!
  $scope.$on('$destroy', function() {
    $scope.modal.remove();
  });
  // Execute action on hide modal
  $scope.$on('modal.hide', function() {
    // Execute action
  });
  // Execute action on remove modal
  $scope.$on('modal.removed', function() {
    // Execute action
  });

});

```

My modal Template looks like that:

```
<script id="modal.content.html" type="text/ng-template">
  <div class="modal">
   <ion-header-bar>
     <h1 class="title">My Modal title</h1>
   </ion-header-bar>
   <ion-content>
     Hello!
   </ion-content>
  </div>
</script>

```

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [May 20, 2014, 12:47pm UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/2 "2014-05-20T12:47:09Z")

</div>

Take a look at our codepen demo, see if you can find any issues with your code compared to ours.

> **[Modal: Nightly](https://codepen.io/ionic/pen/gblny)**
>
> Demo of an Ionc slide up modal....

---

<div class="post-metadata">

**Author:** ![lailo](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lailo](https://forum.ionicframework.com/u/lailo)\
**Post date:** [May 20, 2014, 2:28pm UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/3 "2014-05-20T14:28:29Z")

</div>

Yeah, this version works on iphone but, how can i extract the code inside the script tag in a own html file ?

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [May 20, 2014, 2:37pm UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/4 "2014-05-20T14:37:41Z")

</div>

Just copy the markup with the script tag, and update the link in you js to the right location.

> **[Plunker](http://plnkr.co/edit/zmyZbGe71p1logQhrpfr)**
>
> Created on Plnkr: Helping developers build the web.

---

<div class="post-metadata">

**Author:** ![lailo](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lailo](https://forum.ionicframework.com/u/lailo)\
**Post date:** [May 20, 2014, 2:52pm UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/5 "2014-05-20T14:52:30Z")

</div>

I tried that but as soon as I build and run it on the iPhone, it dose not work.

There is always the following error message:  
**Error: ‘undefined’ is not an object (evaluating ‘a.modal.show’)**

On iPhone this one:  
**Failed to load resource: The requested URL was not found on this server.  
file:///var/mobile/Applications/A4BECCFB-E0FD-4F62-8082-AA540E07D24E/myApp.app/templates/overlays/modal.template.html**

The path is wrong because the template is inside **www/…**

---

<div class="post-metadata">

**Author:** ![lailo](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lailo](https://forum.ionicframework.com/u/lailo)\
**Post date:** [May 22, 2014, 8:40am UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/6 "2014-05-22T08:40:15Z")

</div>

Any idea why it is so ?

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [May 22, 2014, 1:00pm UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/7 "2014-05-22T13:00:08Z")

</div>

I just updated to the nightly builds and I’m not getting that error.

[http://embed.plnkr.co/zmyZbGe71p1logQhrpfr/preview](http://embed.plnkr.co/zmyZbGe71p1logQhrpfr/preview)

The errors are most likely due to an error in your javascript. Can you put together a codepen or plunker?

---

<div class="post-metadata">

**Author:** ![lailo](https://avatars.discourse-cdn.com/v4/letter/l/e56c9b/32.png) [@lailo](https://forum.ionicframework.com/u/lailo)\
**Post date:** [May 22, 2014, 1:31pm UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/8 "2014-05-22T13:31:26Z")

</div>

It happens at the following app repo:

[https://github.com/lsadiki/IonicKitchenSink](https://github.com/lsadiki/IonicKitchenSink)

Could you try to fix it and do a pull request ?  
It is not extracted at this version but you could try to do it.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [May 22, 2014, 2:24pm UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/9 "2014-05-22T14:24:39Z")

</div>

Not getting the error.

---

<div class="post-metadata">

**Author:** ![adampfoster](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/adampfoster/32/67704_2.png) [@adampfoster](https://forum.ionicframework.com/u/adampfoster)\
**Post date:** [December 21, 2015, 7:29am UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/10 "2015-12-21T07:29:00Z")

</div>

I was just having a similar problem where my modal was fine in browser via **ionic serve** , but was unresponsive after running **ionic build** and running my app on hardware.

Basically, watch your paths. My modal html was being referenced as ‘/templates/modal.content.html’ when it should have been ‘templates/modal.content.html’ (depending on your directory structure) since the root on web isn’t the root on iOS or Android

---

<div class="post-metadata">

**Author:** ![techhysahil](https://avatars.discourse-cdn.com/v4/letter/t/c4cdca/32.png) [@techhysahil](https://forum.ionicframework.com/u/techhysahil)\
**Post date:** [May 3, 2016, 4:17pm UTC](https://forum.ionicframework.com/t/bug-modal-ios-and-web/4518/11 "2016-05-03T16:17:27Z")

</div>

For me it’s **working on IOS emulator and browser but working on IONIC APP**. Does it work for Ionic App for anyone? If its does please help me out.
