title: Angular 10 : Is there any way to get the selected DataList object
body: <p>Was creating an Input field with DataList. I was trying to get the object associated with selected option. I was able to get the selected value but not the whole object. I saw some earlier posts where the Datalist items are Unique. In such case we can filter the result based on the selected item &amp; we have only one object corresponding to the selected value.</p>
  <p>In my case the DataList items are not unique.</p>
  <p>public userDetails: Array  = [
  {userID: 1, userName: 'user 1'}, {userID: 2, userName: 'user 2'}, {userID: 11, userName: 'user 1'}]</p>
  <p>Here the items that we are displaying is userName and it's not unique. I need to get the userID corresponding to selected item.</p>
  <pre><code>&lt;input type=&quot;text&quot; class=&quot;form-control&quot; list=&quot;datalist1&quot;/&gt;
  &lt;datalist id=&quot;datalist1&quot;&gt;
       &lt;option *ngFor=&quot;let user of userDetails&quot; [value]=&quot;user.displayName&quot; (click)=&quot;selected(user)&quot;&gt;
           {{ user.displayName }}
       &lt;/option&gt;
  &lt;/datalist&gt;
  </code></pre>