title: Angular-UI Bootstrap Modal trigger on page load
body: <p>Whilst I have looked at the <a href="https://stackoverflow.com/questions/24780767/angular-bootstrap-modal-open-onload">answers here</a>, I'm still unable to trigger my <code>openModal()</code> function on page load. </p>
  
  <p>Within my controller, I have the code (below question), which does allow <code>openModal()</code> to trigger fine either from an ng-click directive or when entering the following in the Chrome console:</p>
  
  <p><code>angular.element($0).scope().openModal()</code></p>
  
  <p>My problem is when I'm trying to conditionally open the modal upon page load. My current code is:</p>
  
  <pre><code>$scope.openModal = function (size) {
  
      modalInstance = $modal.open({
          templateUrl: 'myModalContent.html',
          controller: 'pageBuilder',
          size: 'lg',
          resolve: {
              items: function () {
                  return $scope.chosenDeploymentSchedule;
              }
          }
      });
  };
  
  angular.element(document).ready(function () {
  
  //  $scope.openModal();
      console.log('Hello World');
  });
  </code></pre>
  
  <p>I do get my <code>Hello World</code> printing, but when I try uncommenting the <code>$scope.openModal();</code>, I get an infinite loop of <code>undefined</code> + <code>Hello World</code> printing out.</p>