title: AngularJS - Directive does not obtain controller data
body: <p>need some help on angular.
  i have a directive and i want to get the controller on the link function:</p>
  
  <pre><code> link : function (scope, element, attr, ctrl) {
  //DO Something
  }
  </code></pre>
  
  <p>apparently it is an easy task, and it does work if i predefined the "ng-model" like here :</p>
  
  <pre><code>&lt;numric ng-model="data.mytext" /&gt;
  </code></pre>
  
  <p>but i want to use <code>numric</code> as an attribute and to get the model from it:</p>
  
  <pre><code>&lt;div numric ="data.mytext" &gt;&lt;/div&gt;
  </code></pre>
  
  <p>and now when i get to the link function <code>ctrl</code> is null.
  my code:</p>
  
  <pre><code> &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;Angular JS demo&lt;/title&gt;
    &lt;script src="http://code.jquery.com/jquery-1.10.2.js"&gt;&lt;/script&gt;
  
    &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body ng-app="myApp"&gt;
  &lt;div ng-controller="firsttimeCtrl"&gt;
      &lt;div numric="data.mytext" /&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  &lt;script type="text/javascript"&gt;
  
  var myapp=angular.module('myApp',[]);
  
  myapp.controller('firsttimeCtrl',function ($scope) {
         //$scope.data=Data;
  
      });
  
  
  myapp.directive('numric', function() {
    return {    
      require: '?ngModel',
      replace: true,
  
      link:function (scope, element, attr, ctrl) {
  
        function numricAddCommas(text){
        var str = text.replace(/[^0-9]/g, '');//allowing only numbers
          var parts = (str + "").split("."),
              main = parts[0],
              len = main.length,
              output = "",
              i = len - 1;
  
          while(i &gt;= 0) {
              output = main.charAt(i) + output;
              if ((len - i) % 3 === 0 &amp;&amp; i &gt; 0) {
                  output = "," + output;
              }
              --i;
          }
          // put decimal part back
          if (parts.length &gt; 1) {
              output += "." + parts[1];
          }
          if(output !== text) {
              str=output;
              ctrl.$setViewValue(output);
              ctrl.$render();
          }
          return output;
  
      }
  
          ctrl.$parsers.push(numricAddCommas);
      },
      template:'&lt;input type="text" /&gt;'
  
  
    }; 
  });
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>there is a way to know what controller i'm in by using the template? or there is another way?
  Thanks.</p>