title: AngularJS - ng-change as an option in a custom directive
body: <p>I want to add an <code>ng-change</code> function into a custom directive but I'm not sure if <code>ng-change</code> will go inside the template or into link function, additionally I'd like to make the <code>ng-change</code> optional (calling '</p>
  
  <p>&lt;text-edit-in-place value="loan.due_date" change="checkException"
   param="foobar"></p>
  
  <p>' would add the <code>checkException('foobar')</code> function where leaving out change= &amp; param= would not run any <code>ng-change</code>).</p>
  
  <pre><code>function TextEditInPlaceDirective() {
      return {
          restrict: 'E',
          scope: {
              value: '='
          },
          template: '&lt;span ng-click="edit()" ng-show="!editing"&gt;{{ value}}&lt;/span&gt;&lt;input ng-model="value" ng-blur="onBlur()" ng-show="editing"&gt;&lt;/input&gt;',
          link: function($scope, element, attrs) {
              var inputElement = element.find('input');
  
              // reference the input element
              element.addClass('edit-in-place');
  
              // Initially, we're not editing.
              $scope.editing = false;
  
              // ng-click handler to activate edit-in-place
              $scope.edit = function() {
                  $scope.editing = true;
  
                  // element not visible until digest complete
                  // timeout causes this to run after digest
                  setTimeout(function() {
                      inputElement[0].focus();
                  });
              };
  
              $scope.onBlur = function() {
                  $scope.editing = false;
              };
          }
      };
  }
  </code></pre>
  
  <p>Help would appreciated, Thanks.</p>