title: AngularJS - ng:model - Field is readonly when bound to $q promise?
body: <p>I'm attempting to return a single record from a promise in AngularJs (1.0.7) and bind the result to a form. The form binds correctly, however the input fields are read-only - I cannot edit the values. </p>
  
  <p>If instead I wrap the record in an Array and iterate using ng:repeat, the form binds correctly and I can edit values.</p>
  
  <p>I've created a plnkr that demonstrates the issue clearly: </p>
  
  <p><a href="http://embed.plnkr.co/fOWyhVUfekRbKUSRf7ut/preview">http://embed.plnkr.co/fOWyhVUfekRbKUSRf7ut/preview</a></p>
  
  <p>You can edit the directly bound and list bound input fields, however the field bound to the single promise cannot be edited.</p>
  
  <p>Is it possible to bind ng:model directly to an object returned from a promise, or do I need to use an array to get this to work?</p>
  
  <pre><code>app.controller('MainCtrl', function($scope, $timeout, $q) {
  
    var person = {"name": "Bill Gates"}
  
    var deferList = $q.defer();
    var deferSingle = $q.defer();
  
    // Bind the person object directly to the scope. This is editable.
    $scope.direct = person;       
  
    // Bind a promise to the scope that will return a list of people. This is editable.
    $scope.list   = deferList.promise;
  
    // Bind ap romise to the scope that will return a single person record. This is *not* editable.
    $scope.single = deferSingle.promise;
  
    // Resolve the promises
    $timeout( function(){
      deferList.resolve( [person] );  // Array
      deferSingle.resolve( person );  // Just the record itself
    }, 100);
  
  
  });
  
  
  &lt;body ng-controller="MainCtrl"&gt;
      Directly Bound - This field is editable
          &lt;input ng:model="direct.name"/&gt;
      &lt;hr/&gt;
      Singleton Promise - This field is *not* editable.
          &lt;input ng:model="single.name"/&gt;    
      &lt;hr/&gt;
      List Promise: - This field is editable
          &lt;div ng:repeat="person in list"&gt;
              &lt;input ng:model="person.name"/&gt;  
          &lt;/div&gt;
  
   &lt;/body&gt;
  </code></pre>
  
  <p><strong>Edit</strong>: After some debugging, I've found that the ng:model directive is <em>reading</em> from the value ('$$v') component of the promise, but writing directly to the promise object itself.</p>
  
  <p>When attempting to edit the promise, the ViewModel keeps being reverted back to the original value, while storing characters on the promise itself. Thus if the user types 'asdf' into the input field, the result would be the following.</p>
  
  <pre><code>{Name: "Asdf", $$v: {Name: "Bill Gates"}}
  </code></pre>
  
  <p>Whereas we should instead be expecting</p>
  
  <pre><code>{$$v: {Name: "asdf"}}
  </code></pre>
  
  <p>Am I doing something wrong, or is this potentially a bug in AngularJS?</p>
  
  <p>(To further clarify, the issue is the difference in behaviour between an Array and an Object returned by a promise. The direct binding is simply there as a control)</p>