title: $scope.modal remains undefined on $ionicPlatform.ready
body: <p>I've been looking everywhere for an answer to this problem; I wouldn't mind but it was actually working earlier. I'm trying to open a modal in an Ionic App on load of the app if there is no user access token stored in localStorage.</p>
  
  <p>This is the code I'm working with:</p>
  
  <p>JS</p>
  
  <pre><code>.controller('LeagueCtrl', function($scope, $ionicModal, $ionicPlatform, $cordovaOauth, Spotify, Favourites) {
    $scope.favourites = Favourites.all();
  
    $ionicModal.fromTemplateUrl('templates/login.html', {
      scope: $scope,
      animation: 'slide-in-up'
    }).then(function (modal) {
      $scope.modal = modal;
      console.log($scope.modal);
    });
  
    $scope.openModal = function() {
      $scope.modal.show();
    };
  
    $scope.closeModal = function() {
      $scope.modal.hide();
    };
  
  ...
  
    $scope.loginSpotify = function () {
      $cordovaOauth.spotify('583ac6ce144e4fcb9ae9c29bf9cad5ef', ['user-read-private']).then(function(result) {
          window.localStorage.setItem('spotify-token', result.access_token);
          Spotify.setAuthToken(result.access_token);
          $scope.updateInfo();
          //$scope.closeModal();
      }, function(error) {
        console.log("Error -&gt; " + error);
      });
    };
  
    $scope.updateInfo = function() {
      Spotify.getCurrentUser().then(function(data) {
        $scope.getUserPlaylists(data.id);
      }, function(error) {
        $scope.loginSpotify();
      });
    };
  
    $ionicPlatform.ready(function() {
      var storedToken = window.localStorage.getItem('spotify-token');
      if (storedToken !== null) {
        Spotify.setAuthToken(storedToken);
        $scope.updateInfo();
      } else {
        $scope.openModal();
        alert('ionicPlatform ready');
      }
    });
  
  })
  </code></pre>
  
  <p>HTML</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"&gt;
      &lt;title&gt;&lt;/title&gt;
  
  
      &lt;link href="css/ionic.app.css" rel="stylesheet"&gt;
  
      &lt;script src="lib/ionic/js/ionic.bundle.js"&gt;&lt;/script&gt;
  
      &lt;script src="lib/ngCordova/dist/ng-cordova.js"&gt;&lt;/script&gt;
      &lt;script src="lib/ng-cordova-oauth/dist/ng-cordova-oauth.min.js"&gt;&lt;/script&gt;
      &lt;script src="lib/angular-spotify/dist/angular-spotify.min.js"&gt;&lt;/script&gt;
      &lt;script src="cordova.js"&gt;&lt;/script&gt;
  
  
      &lt;script src="js/controllers.js"&gt;&lt;/script&gt;
      &lt;script src="js/services.js"&gt;&lt;/script&gt;
      &lt;script src="js/app.js"&gt;&lt;/script&gt;
    &lt;/head&gt;
    &lt;body ng-app="share"&gt;
  
      &lt;ion-nav-bar class="bar-assertive"&gt;
        &lt;ion-nav-back-button&gt;
        &lt;/ion-nav-back-button&gt;
      &lt;/ion-nav-bar&gt;
  
      &lt;ion-nav-view&gt;&lt;/ion-nav-view&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>As I said it was actually working before, opening the modal on startup as expected. Then it just stopped working, and producing an error I'd encountered earlier for no apparent reason. The error is as follows:</p>
  
  <pre><code>ypeError: Cannot read property 'show' of undefined
  at Scope.$scope.openModal (http://localhost:8100/js/controllers.js:24:17)
  at http://localhost:8100/js/controllers.js:60:14
  at http://localhost:8100/lib/ionic/js/ionic.bundle.js:53329:19
  at Object.ionic.Platform.ready (http://localhost:8100/lib/ionic/js/ionic.bundle.js:2135:9)
  at Object.self.ready (http://localhost:8100/lib/ionic/js/ionic.bundle.js:53327:26)
  at new &lt;anonymous&gt; (http://localhost:8100/js/controllers.js:54:18)
  at invoke (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17762:17)
  at Object.instantiate (http://localhost:8100/lib/ionic/js/ionic.bundle.js:17770:27)
  at http://localhost:8100/lib/ionic/js/ionic.bundle.js:22326:28
  at self.appendViewElement (http://localhost:8100/lib/ionic/js/ionic.bundle.js:56883:24) &lt;ion-nav-view name="tab-league" class="view-container tab-content" nav-view="active" nav-view-transition="ios"&gt;
  </code></pre>
  
  <p>Any help would be appreciated massively, I can't grasp what the problem is.</p>