title: AngularJS - Formatting ng-model before template is rendered in custom directive
body: <p>I am creating a custom directive in Angular JS. And I want to format the ng-model before the template renders.</p>
  
  <p>This is what I have so far:</p>
  
  <p>app.js</p>
  
  <pre><code>app.directive('editInPlace', function() {
      return {
          require: 'ngModel',
          restrict: 'E',
          scope: { ngModel: '=' },
          template: '&lt;input type="text" ng-model="ngModel" my-date-picker disabled&gt;'
      };
  });
  </code></pre>
  
  <p>html</p>
  
  <pre><code>&lt;edit-in-place ng-model="unformattedDate"&gt;&lt;/edit-in-place&gt;
  </code></pre>
  
  <p>I want to format the unformattedDate value before it is entered in the ngModel of the template. Something like this:</p>
  
  <pre><code>template: '&lt;input type="text" ng-model="formatDate(ngModel)" my-date-picker disabled&gt;'
  </code></pre>
  
  <p>but that gives me an error. How to do this?</p>