title: AngularJS - Pass Optional Parameter to Modal
body: <p>How do I pass an OPTIONAL parameter to my angularJS modal?  Here is my code:</p>
  
  <p>CONTROLLER A (TRIGGER):</p>
  
  <pre><code>$modal.open({
    templateUrl: 'UploadPartial.html',
    controller: 'photos.uploadCtrl',
    resolve: {
      preselectedAlbum: function preselectedAlbum() {
        return angular.copy($scope.selectedAlbum);
      }
    }
  });
  </code></pre>
  
  <p>CONTROLLER B (MODAL):</p>
  
  <pre><code>app.controller('photos.uploadCtrl', [
    '$scope',
    '$modalInstance',
    '$injector',
    function uploadCtrl($scope, $modalInstance, $injector) {
      if ($injector.has('preselectedAlbum')) {
        console.log('happy');  // I want this to work, but $injector doesn't find it
      } else {
        console.log('sad');  //  Always gets here instead :(
      }
    }
  ]);
  </code></pre>
  
  <p>NOTE: It works when i put <code>preselectedAlbum</code> as a dependency, but then i get the error whenever I don't explicitly pass it in.  I want it to be optional instead.</p>