Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This seems to be by design that the <code>ngModel</code> doesn't handle objects or arrays. In the <a href="https://github.com/angular/angular.js/blob/890e939fcc0e059b66a4868853d82e23fbc68ac3/src/ng/directive/input.js#L1085-L1089" rel="nofollow">ngModelController code L1085-L1089)</a>, an <code>!==</code> operator is used to compare to see if the model value has changed. Since the <code>$modelValue</code> is always equal to the value (<code>xdata</code>) when <code>xdata[*]</code> changes, the <code>ngModelController</code> doesn't detect any changes from the model.</p> <p>However, you can workaround this by adding a watcher in the directive to invalidate the $modelValue whenever the watcher is called.</p> <pre><code>scope.$watchCollection(attr.ngModel, function (newValue, oldValue) { ngModel.$modelValue = oldValue; }); </code></pre> <p>Here is a Plunker that demonstrates this workaround: <a href="http://plnkr.co/edit/mUL577?p=preview" rel="nofollow">http://plnkr.co/edit/mUL577?p=preview</a></p> <p>Another way would be to use the <code>ngChange</code> directive on the <code>input</code> fields to invalidate the model value. However, that introduces coupling between the directives.</p> <hr> <p>There is an issue on AngularJS that is tracking this: <a href="https://github.com/angular/angular.js/pull/2553" rel="nofollow">https://github.com/angular/angular.js/pull/2553</a></p> <p>Also, the <code>split-array</code> directive here is basically doing what <a href="http://docs.angularjs.org/api/ng.directive%3angList" rel="nofollow"><code>ngList</code></a> is doing. However, <code>ngList</code> doesn't respect the separator on when rendering to view (<a href="https://github.com/angular/angular.js/pull/2561" rel="nofollow">https://github.com/angular/angular.js/pull/2561</a>).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload