title: Angular directive scope not reflecting changes in controller scope
body: <p>I am writing a directive that needs to show a search box and a few values in a grid. Entering a search text could change the values in the grid.</p>
  
  <p><a href="http://jsfiddle.net/rtv2222/st55azbg/5/" rel="nofollow">http://jsfiddle.net/rtv2222/st55azbg/5/</a></p>
  
  <pre><code>&lt;div ng-controller="MyCtrl"&gt;
    &lt;my-directive values='some.values' onsearchtextchange='onsearchtextchange' searchtext='some.searchtext'&gt;&lt;/my-directive&gt;
    &lt;/div&gt;
  
    var demo = angular.module('demo', []);
    demo.directive('myDirective', function($parse) {
    return {
      restrict: "E",
      scope: {         
          values: '=',
          searchtext: '=',
          onsearchtextchange: '&amp;'
      },
      template: '{{values.length}} &lt;input ng-model="searchtext"&gt;',
      link:
      function(scope, element, attrs){
          scope.$watch('searchtext', function (tmpStr){
              setTimeout(function() {
                  // if searchStr is still the same..
                  // go ahead and retrieve the data
                  if (tmpStr === scope.searchtext)
                  {
                      scope.onsearchtextchange()(scope.searchtext);
                      console.log(scope.values.length);
                  }
              }, 1000);
          });
      }
  }
  });
  
  function MyCtrl ($scope) {
  $scope.some = {};
  $scope.some.values = [{a:1}, {a:2}];
  $scope.some.searchtext = "";
  $scope.onsearchtextchange = function(searchtext) {
      if (searchtext &amp;&amp; searchtext.length != 0) {
          $scope.some.values = [{a:1}];
          console.log('values.length is:' + $scope.some.values.length);
      }
      else {
          $scope.some.values = [{a:1}, {a:2}];
          console.log('values.length is:' + $scope.some.values.length);
      }
  }
  };
  </code></pre>
  
  <p>I am binding the searchtext, onsearchtextchange callback and the values with an isolate scope to the directive. I $watch the searchtext and make a callback into the controller function which updates the list of values.</p>
  
  <p>I however find that the directive scope does not reflect the change in the value of 'values' on the controller scope.</p>
  
  <p>What should I do so that the child scope is updated whenever the callback updates the values on the controller scope ?</p>
  
  <p>As you can see when you run the example, when the searchtext is changed, the onsearchtextchange callback is called and the controller scope.some.values is changed. The directive scope values is however still the old value.</p>