title: AngularJS : pass ng-model from directive component to controller
body: <p>Inspired by angular ui, I want to create front-end library as a pieces of component, all as an angularjs directive. So that the user can simply put directive with some configurations and get the desire result of component.</p>
  
  <p>So this is how the directive will look like.</p>
  
  <pre><code>&lt;date-picker 
      date-format="MM.DD.YYYY HH:mm" 
      enable-navigation 
      date-picker-id="datetimepicker2"
      date-picker-model="myModel1"&gt;
  &lt;/date-picker&gt;
  </code></pre>
  
  <p>For the usage, the idea is that it could be wrapped by user-created controller and the controller can reach the directive scope like this. </p>
  
  <pre><code>&lt;div ng-controller="myController"&gt;
     &lt;date-picker 
           ...
         date-picker-model="myModel1"&gt;
     &lt;/date-picker&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>(The reason I use component-name-model is because the component directive template might have more than one model) And the code in controller would be </p>
  
  <pre><code>angular.module('myApp').controller('myController',['$scope', function($scope) {
       $scope.myModel1; //this scope binds to the datepicker template scope 
  }]);
  </code></pre>
  
  <p>Since I'm pretty new to angularJs, my questions are follow.</p>
  
  <ol>
  <li><p>How to make the controller reach the directive scope with this syntax ? In my case, It seems that the controller didn't notice about directive scope (see my code in plunker)</p></li>
  <li><p>Right now I'm also stuck with passing model to the template. as you can see in directive I've define <em>date-picker-model="myModel1"</em> and then directive will catch attrs and pass it to template like this</p>
  
  <pre><code>if('datePickerModel' in attrs){
       $scope.datePickerModel = attrs.datePickerModel;
  }
  </code></pre>
  
  <p>and when I'm using expression on templateUrl, ng-model="{{datePickerModel}}" doesn't work</p></li>
  </ol>
  
  <p>The code is quite long so I would suggest you the check out my <a href="http://plnkr.co/edit/JAMwC5YqJtuqo5pdf31u" rel="nofollow">plunker</a></p>
  
  <p>Thank you :-)</p>