title: Angular: selected on option of select doesn't work as excepted while using along with ngModel
body: <p>I have an array of objects(named <strong>users</strong>) which will be shown as options of <code>dropdownlist</code>. and I have another objects list(named <strong>selectedUsers</strong> and is saved in backend) which is used to initialize the <code>dropdownlist</code>.  </p>
  
  <p>array:</p>
  
  <pre><code>users = [
    {
      id: 2,
      name: 'name2'
    },{
      id: 2,
      name: 'name2'
    },{
      id: 3,
      name: 'name3'
    }
  ];
  
  selectedUsers3 = [
    {
      id: 1,
      name: 'name1'
    },{
      id: 2,
      name: 'name2'
    }
  ];
  </code></pre>
  
  <p>I'm facing a wired situation which is when I bind <code>Object</code> to <code>select options</code> by <code>[ngValue]</code>, and bind a function to <code>[selected]</code> which will check whether the current option exists in <code>selectedUsers</code>. </p>
  
  <p>I can see the function is retrieved and the result is returned true/false as excepted, but the options keeps unselected.</p>
  
  <p>template:</p>
  
  <pre><code>&lt;select multiple [(ngModel)]="selectedUsers3"&gt;
    &lt;option *ngFor="let user of users" [selected]="checkExist(user)" [ngValue]="user"&gt;{{user.name}}&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>function in component:</p>
  
  <pre><code>checkExist(user) {
    return this.selectedUsers3.findIndex(selUser =&gt; selUser.id === user.id) &gt; -1;
    //return this.selectedUsers3.filter(selUser =&gt; selUser.id === user.id).length &gt; 0;
  }
  </code></pre>
  
  <p>mention that I used <code>Array.filter</code> or <code>Array.findIndex</code> to check whether the data exists, and the result is correct.</p>
  
  <p>Please refer this <a href="https://plnkr.co/edit/QLAnfB98o52Eqxf56Knh?p=preview" rel="nofollow noreferrer">demo</a> with the third <code>dropdownlist</code>, and check where am I doing something wrong? or am I missing something about <code>[selected]</code>? I hope someone can explain clearly about this.</p>
  
  <p><strong>UPD:</strong></p>
  
  <p>with @Günter Zöchbauer's help, this situation can be solved by using <code>compareWith</code> directive(refer his answer) no matter <code>single select</code> or <code>multi select</code>, but I'm still confused why they work well alongside but fail together and still trying to figure out the reason.</p>