title: How to access the AngularJS ui-bootstrap datepicker value in my controller
body: <p>I am using the AngularJS Bootstrap UI library. In my view I have the datepicker directive like so...</p>
  
  <pre><code>&lt;div datepicker ng-model="mt" min-date="minDate" max-date="maxDate" year-range="1" show-weeks="false" &gt;&lt;/div&gt;
  </code></pre>
  
  <p>I've noticed that when I try to reference the value of "mt" in my controller it is always undefined whilst it is correct / updates in the view. For example here is my controller code:</p>
  
  <pre><code>if(something === true) {
    console.log({ people: $scope.guestNumber, resTime: $scope.resTime, ddmmyyyy: $scope.mt }); // $scope.mt is always undefined!!!! 
  }
  </code></pre>
  
  <p>Obviously this must be due to the directive having its own scope.... so my question is, how do I access the value of "mt" in my controller. I was going to use a hidden form input but this feels a little dirty to me (and I am unsure if it will work), like so:</p>
  
  <pre><code>&lt;div datepicker ng-model="mt" min-date="minDate" max-date="maxDate" year-range="1 show-weeks="false" &gt;&lt;/div&gt;
  &lt;input type="text" ng-model="hiddenDate" value="{{ mt }}"&gt;
  </code></pre>
  
  <p><strong><em></strong> UPDATE <strong></em></strong></p>
  
  <p>I have noticed that this bug only seems to happen when my datepicker is in a modal window provided by ui.bootstrap.modal. The service I have for the models looks like so:</p>
  
  <pre><code>factory('modalService', function ($modal) {
  
          var modal = angular.copy($modal);
  
          // standard modal for alerts
          modal.reservationMenu = function(message, title) {
              var options = {
                  templateUrl: '../../views/modal/model-form.html',
                  controller: 'ModalMenuCtrl',
                  resolve: {
                      things: function() {
                          return {
                              title: title,
                              message: message
                          };
                      }
                  },
                  windowClass: 'menu-dia'
              };
              return modal.open(options);
          };
  
          return modal;
      })
  
  ;
  </code></pre>
  
  <p>If I set the value of the datepicker in my controller, the date is never updated!</p>