title: AngularJS: Parent scope is not updated in directive (with isolated scope) two way binding
body: <p>I have a directive with isolated scope with a value with two way binding to the parent scope. I am calling a method that changes the value in the parent scope, but the change is not applied in my directive.(two way binding is not triggered). This question is very similar: </p>
  
  <p><a href="https://stackoverflow.com/questions/19391773/angularjs-parent-scope-not-updated-in-directive-with-isolated-scope-two-way-b">AngularJS: Parent scope not updated in directive (with isolated scope) two way binding</a></p>
  
  <p>but I am not changing the value from the directive, but changing it only in the parent scope. I read the solution and in point five it is said: </p>
  
  <pre><code>The watch() created by the isolated scope checks whether it's value for the bi-directional binding is in sync with the parent's value. If it isn't  the parent's value is copied to the isolated scope.
  </code></pre>
  
  <p>Which means that when my parent value is changed to 2, a watch is triggered. It checks whether parent value and directive value are the same - and if not it copies to directive value. Ok but my directive value is still 1 ... What am I missing ?</p>
  
  <p>html :</p>
  
  <pre><code>&lt;div data-ng-app="testApp"&gt;
      &lt;div data-ng-controller="testCtrl"&gt;
          &lt;strong&gt;{{myValue}}&lt;/strong&gt;
          &lt;span data-test-directive data-parent-item="myValue" 
              data-parent-update="update()"&gt;&lt;/span&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>js: </p>
  
  <pre><code>var testApp = angular.module('testApp', []);
  
  testApp.directive('testDirective', function ($timeout) {
      return {
          scope: {
              key: '=parentItem',
              parentUpdate: '&amp;'
          },
          replace: true,
          template:
              '&lt;button data-ng-click="lock()"&gt;Lock&lt;/button&gt;' +
              '&lt;/div&gt;',
          controller: function ($scope, $element, $attrs) {
              $scope.lock = function () {
                  console.log('directive :', $scope.key);
  
                   $scope.parentUpdate();
                   //$timeout($scope.parentUpdate); // would work.
  
                   // expecting the value to be 2, but it is 1
                   console.log('directive :', $scope.key);
              };
          }
      };
  });
  
  testApp.controller('testCtrl', function ($scope) {
      $scope.myValue = '1';
      $scope.update = function () {
          // Expecting local variable k, or $scope.pkey to have been
          // updated by calls in the directive's scope.
          console.log('CTRL:', $scope.myValue);
          $scope.myValue = "2";
          console.log('CTRL:', $scope.myValue);
      };
  });
  </code></pre>
  
  <p><a href="http://jsfiddle.net/u69PT/17/" rel="nofollow noreferrer">Fiddle</a></p>