title: Ionic Modal not opening (TypeError: Cannot read property 'show' of undefined)?
body: <p>I am making an ionic + angularJs app, for Android to be specific. I don't know why, but in my so named <code>homeController</code>, whenever I tried to call a function to show me a <code>$ionicModal</code>, it gives me an error...</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'show' of undefined at
    Scope.$scope.openModal (homeModule.js:18) at new 
    (homeModule.js:59) at Object.invoke (ionic.bundle.js:11994) at
    $get.extend.instance (ionic.bundle.js:16247) at ionic.bundle.js:15502
    at forEach (ionic.bundle.js:8155) at nodeLinkFn
    (ionic.bundle.js:15501) at compositeLinkFn (ionic.bundle.js:14887) at
    publicLinkFn (ionic.bundle.js:14766) at
    IonicModule.controller.self.appendViewElement (ionic.bundle.js:47324)</p>
  </blockquote>
  
  <p>My controller looks like this (the start of it):</p>
  
  <pre><code>app.controller('homeController', function($scope, $ionicPopup, $state, $ionicLoading, $rootScope, $ionicModal, mapFactory){
      // Load the modal from the given template URL
      $ionicModal.fromTemplateUrl('templates/loginModal.html', function($ionicModal) {
        $scope.modal = $ionicModal;
        console.log($scope.modal);
      }, {
        scope: $scope,
        animation: 'slide-in-up',
        backdropClickToClose: false,
        hardwareBackButtonClose: false,
        focusFirstInput: true
      });
      $scope.openModal = function() {
          $scope.modal.show();
      };
      $scope.closeModal = function() {
          $scope.modal.hide();
      };
  </code></pre>
  
  <p>I have tried already many different ways to make the modal open, the funny thing is, whenever I go to a new $state, and go back, it opens... But not when I refresh the page. Also, I did a <code>console.log($scope.modal)</code> to see if my variable was being set, and the result was: </p>
  
  <pre><code>ionic.Utils.inherit.child {focusFirstInput: true, unfocusOnHide: true, focusFirstDelay: 600, backdropClickToClose: false, hardwareBackButtonClose: false…}$el: JQLite[1]animation: "slide-in-up"backdropClickToClose: falseel: div.modal-backdropfocusFirstDelay: 600focusFirstInput: truehardwareBackButtonClose: falsemodalEl: ion-modal-view.modalscope: ChildScopeunfocusOnHide: trueviewType: "modal"__proto__: ionic.Utils.inherit.Surrogate 
  </code></pre>
  
  <p>Can anyone please help me on this one? Thanks in advance.</p>