title: Android Phonegap app + AngularJS: Update $scope with selected date on android DatePicker
body: <p>I created a plugin for my phonegap app, which calls a native android "DatePicker" controll. The DatePicker is invoked in this way:</p>
  
  <p>There is a checkbox on the view. When the user check's the checkbox, I invoke the DatePicker. After selecting a date and pressing confirm, an event is fired an I get the date selected. The problem is, inside this event, I don't have the $scope. Even though I try to set it and it does not get updated. I imagine that this happen because the $scope is not in the context when the event is fired. </p>
  
  <p>I need to have the date that the user selected to make some validation, and allow he to save the changes. Here is my view and controller:</p>
  
  <p>View (shortned for simplification purpose)</p>
  
  <pre><code>    &lt;div&gt;
          &lt;span&gt;Status&lt;/span&gt; &lt;br /&gt;
          &lt;label&gt;
              &lt;!-- When this checkbox is checked, I invoke the DatePicker--&gt;
              &lt;input type="checkbox" ng-model="resolved" ng-click="openCalendar()"&gt;
              &lt;div &gt;&lt;/div&gt;Item Resolved
          &lt;/label&gt;
      &lt;/div&gt;
  
      &lt;div class="center"&gt;
          &lt;button ng-disabled="!resolved"&gt;Save&lt;/button&gt;
          &lt;button&gt;Cancel&lt;/button&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>myappControllers.controller('ItemDetailsController', 
  ['$scope', '$routeParams', 'Notification', function ($scope, $routeParams, Notification) {
  
  $scope.notification= Notification.getNotification($routeParams.Id);
  
  $scope.resolved = false;
  
  $scope.date = '';
  
  //This event is fired when the user check's the checkbox
  $scope.openCalendar = function(){ 
  
      // defining options
      var options = {
        date: new Date(),
        mode: 'date'
      };
  
      //This event is fired when the user has selected a date on the DatePicker
      datePicker.show(options, function(date){ 
  
          $scope.date = date //Does not get updated!
  
      });
  }
  
  //Function for save button
  $scope.save = function(){
  
     if($scope.date){
        //save the changes
     }
  }
  
  }]);
  </code></pre>
  
  <p>How do I handle this?</p>