title: AngularJS directive's isolated scope loses reference to parent
body: <p><strong>UPDATE:</strong>
  I have found a workaround. In the parent scope I create an object, then I bind the object's property to the input directive like that:</p>
  
  <pre><code>//Parent controller
  $scope.data = {};
  //Parent directive template
  template: '&lt;custom-input model="data[\'test\']"&gt;&lt;/custom-input&gt;',
  </code></pre>
  
  <p>In this case, everything works. However, it at least feels unnatural to create an extra object for that. I believe a more elegant solution exists.</p>
  
  <hr>
  
  <p>In my angularjs (1.2.27) application, I have a directive which is a custom input element, it helps a user to find specific row in the database and then returns the row as a javascript object. I want to expose the selected element to the outer scope, so I use two-directional binding. However, when a user selects something, parent scope is not notified about the changes, child directive's scope is. You can see example code below:</p>
  
  <pre><code>app.controller('customInputController', ['$scope', function($scope) {
      $scope.$watch('model', function(value){
          console.log('Child controller model updated!');
      });
      //This function is called when a user has selected an object,
      $scope.select = function(object) {
          //I believe the error is hiding nearby
          $scope.model = angular.copy(object);
      }
  }]);    
  app.directive('customInput', function() {
      return {
          restrict: 'E',
          template: '...',
          scope: {
              model: '='
          },
          controller: 'customInputController'
      }
  });
  app.controller('parentController', ['$scope', function($scope) {
      $scope.$watch('test', function(value){
          console.log('Parent controller test updated!');
      });
  }]);
  app.directive('parent', function() {
      return {
          restrict: 'E',
          template: '&lt;custom-input model="test"&gt;&lt;/custom-input&gt;',
          controller: 'parentController'
      }
  });
  </code></pre>
  
  <p>Still, if I add a following line to the parent controller:</p>
  
  <pre><code>$scope.test = { name: "test" };
  </code></pre>
  
  <p>Both scopes are notified about this change, so it came to my mind that initially, binding takes place, but when in child scope the <strong>model</strong> gets reassigned, parent scope loses reference to the variable. </p>
  
  <p>This makes me sort of confused, why does reassigning the variable in child scope breaks everything, is not it the way the binding is intended to be used? Obviously, the code provided is not the actual code I have trouble with, it is not possible to post it here, so there is a chance I am missing something that actually causes the error.</p>
  
  <p>Thanks in advance.</p>