title: How to implement an ng-change for a custom directive
body: <p>I have a directive with a template like</p>
  
  <pre><code>&lt;div&gt;
      &lt;div ng-repeat="item in items" ng-click="updateModel(item)"&gt;
  &lt;div&gt;
  </code></pre>
  
  <p>My directive is declared as:</p>
  
  <pre><code>return {
      templateUrl: '...',
      restrict: 'E',
      require: '^ngModel',
      scope: {
          items: '=',
          ngModel: '=',
          ngChange: '&amp;'
      },
      link: function postLink(scope, element, attrs) 
      {
          scope.updateModel = function(item)
          {
               scope.ngModel = item;
               scope.ngChange();
          }
      }
  }
  </code></pre>
  
  <p>I would like to have <code>ng-change</code> called when an item is clicked and the value of <code>foo</code> has been changed already.</p>
  
  <p>That is, if my directive is implemented as:</p>
  
  <pre><code>&lt;my-directive items=items ng-model="foo" ng-change="bar(foo)"&gt;&lt;/my-directive&gt;
  </code></pre>
  
  <p>I would expect to call <code>bar</code> when the value of <code>foo</code> has been updated.</p>
  
  <p>With code given above, <code>ngChange</code> is successfully called, but it is called with the old value of <code>foo</code> instead of the new updated value.</p>
  
  <p>One way to solve the problem is to call <code>ngChange</code> inside a timeout to execute it at some point in the future, when the value of <code>foo</code> has been already changed. But this solution make me loose control over the order in which things are supposed to be executed and I assume that there should be a more elegant solution.</p>
  
  <p>I could also use a watcher over <code>foo</code> in the parent scope, but this solution doesn't really give an <code>ngChange</code> method to be implmented and I have been told that watchers are great memory consumers.</p>
  
  <p>Is there a way to make <code>ngChange</code> be executed synchronously without a timeout or a watcher? </p>
  
  <p>Example: <a href="http://plnkr.co/edit/8H6QDO8OYiOyOx8efhyJ?p=preview">http://plnkr.co/edit/8H6QDO8OYiOyOx8efhyJ?p=preview</a></p>