title: get value of datepicker directive in angular js
body: <p>This was the code I was using before...</p>
  
  <pre><code>&lt;div class="date_menu" ng-repeat="singledate in dates"&gt;
      &lt;p&gt;
      {{singledate}}
  
      &lt;input type="radio" name="filterDateChosen2" ng-model="$parent.radioResult" ng-value="singledate"&gt;
      &lt;/p&gt;
  &lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>This displayed a list of dates in the form of radio buttons. This saved the selected date in <code>$parent.radioResult</code> where I was able to then access it with...</p>
  
  <pre><code>&lt;button ng-click="getVar(radioResult)"...
  </code></pre>
  
  <p>But now, I want to use jQuery datepicker instead...</p>
  
  <pre><code>myApp.directive('calendar', function () {
      return function(scope, element, attrs) {
         element.datepicker({
             inline: true,
             dateFormat: 'dd-mm-yy',
             onSelect: function(dateText) {
                 var modelPath = $(this).attr('ng-model');
                 var val = $(this).attr('ng-value');
                 putObject(modelPath, val, scope, dateText);
                 scope.$apply();
             }
         });
     }
  });
  </code></pre>
  
  <p>This works, if I select a date, the input box will show it...</p>
  
  <pre><code>&lt;input calendar ng-model="$parent.radioResult" /&gt;
  </code></pre>
  
  <p>But the problem is, when I use...</p>
  
  <pre><code>&lt;button ng-click="getVar(radioResult)"...
  </code></pre>
  
  <p>It does not get the value, and I cannot figure out why? What is the reason for this?</p>