title: Angular attribute directive add ng-change
body: <p>I have a directive defined as:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>module.directive('inputChanged', function () {
          function link(scope, element, attrs) {
              var field = attrs.ngModel;
              if (field) {
                  var fn = "model.changed('" + field + "')";
                  element.attr('ng-change', fn);
              }            
          }
  
          return {
              restrict: 'A',
              link: link
          }
      });</code></pre>
  </div>
  </div>
  </p>
  
  <p>which I am using like:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input ng-model="model.user.middleName" input-changed type="text" class="k-textbox"&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The goal is to dynamically inject the ng-change with the model field as parameter. My scenario is actually a bit more complex, but I am simplifying it for this question.  This is why I need to inject it dynamically and not place it directly in the input markup.</p>
  
  <p>This works and I can see the ng-change in the markup once the page is rendered.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input ng-model="model.user.middleName.value" type="text" class="k-textbox ng-valid ng-not-empty ng-dirty ng-valid-parse ng-touched" ng-change="model.changed('model.user.middleName.value')" aria-invalid="false"&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>The problem is that model.changed(...) is not firing.  If I hardcode it instead of using the directive, everything works as expected.</p>
  
  <p>What am I missing?  </p>
  
  <p>Thank you.</p>