title: Angular: How to populate a dynamic array for select using ngOptions?
body: <p>Ideally, I want to populate the array via computed property. For example,</p>
  
  <pre><code>    Object.defineProperty(MyObj.prototype, 'linkedList', {
          get: function () {
              var list = [];
              this.dataList.forEach(function (cs) {
                  if (cs !== this) {
                      list.push(cs.name);
                  }
              });
              return list;
          }
      });
  </code></pre>
  
  <p>However, if I used this computed property as select options like</p>
  
  <pre><code>&lt;select data-ng-model="name" data-ng-options="g for g in myObj.linkedList"&gt;&lt;/select&gt;
  </code></pre>
  
  <p>I will get this error:</p>
  
  <pre><code>Error: 10 $digest() iterations reached. Aborting!
  </code></pre>
  
  <p>In fact, I still get this error even if I return a fixed list like:</p>
  
  <pre><code>    Object.defineProperty(MyObj.prototype, 'linkedList', {
          get: function () {
              return ['test1', 'test2'];
          }
      });
  </code></pre>
  
  <p>However, it is okay if I return a static array:</p>
  
  <pre><code>MyObj._linkedList = ['test1', 'test2'];
  
    Object.defineProperty(MyObj.prototype, 'linkedList', {
          get: function () {
              return MyObj._linkedList;
          }
      });
  </code></pre>
  
  <p>I also tried to use a filter in the ngOptions and the same error is thrown. Why and How?</p>
  
  <p>UPDATE:</p>
  
  <p>As it turns out, my original question above doesn't truly reflect the problem, because the problem happens only if I use a directive. To simplify the question, I removed the directive part.</p>
  
  <p>Anyway, in my directive, I have </p>
  
  <pre><code>    scope: {
          name: '=',
          isEditing: '=',
          isHidden: '=',
          options: '='
      }
  
  &lt;div&gt;
      &lt;div data-ng-hide="!isHidden" style="background-color: lightgrey"&gt;&amp;nbsp;&lt;/div&gt;
      &lt;div data-ng-show="!isEditing &amp;&amp; !isHidden"&gt;{{name}}&lt;/div&gt;
      &lt;select class="select-input"  data-ng-show="isEditing &amp;&amp; !isHidden" data-ng-model="name" data-ng-options="g for g in {{options}}"&gt;&lt;option value=""&gt;&lt;/option&gt;&lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is how to use it:</p>
  
  <pre><code>&lt;td&gt;&lt;ms-table-select-cell name="myObj.link" is-editing="myObj.isEditing" options="myObj.linkedList" /&gt;&lt;/td&gt;
  </code></pre>
  
  <p>This is how the error occurs. If I directly use the select tag with ngOptions, it's not a problem.</p>