How to get datalist selected options id's value with ng-repeat and fillter?
<p>I used datalist to search the value which I entered in input field and filtered. I need to send selected options id to the controller function.</p>
<pre><code>&lt;input list=&quot;browsers&quot; type=&quot;text&quot; id=&quot;searchtextbox&quot; class=&quot;form-control&quot; placeholder=&quot;Search&quot; ng-model=&quot;searchText&quot;&gt;
&lt;datalist id=&quot;browsers&quot;&gt;
       &lt;option ng-repeat=&quot;data in enroldata | filter: searchText&quot; id=&quot;{{data.USERID}}&quot; id=&quot;{{data.USERID}}&quot; value=&quot;{{data.FIRSTNAME}} {{data.LASTNAME}}&quot;&gt;{{data.FIRSTNAME}} {{data.LASTNAME}}&lt;/option&gt;
 &lt;/datalist&gt;
  &lt;input type=&quot;button&quot; class=&quot;btn btn-primary btn-flat&quot; ng-click=&quot;enrol({{data.USERID}})&quot; value=&quot;Send&quot; /&gt;
</code></pre>
<p>In controller</p>
<pre><code> $scope.enrol = function (USERID) {
        debugger;
        var value = $scope.USERID;
        var val = $('#searchtextbox').val();
        var states = $('#browsers');
        var endVal = $(states).find('option[value=&quot;' + val + '&quot;]');
        //depending on your logic, if endVal is empty it means the value wasn't found in the datalist, you can take some action here
        return endVal.text();

      
        var USERID1 = $scope.searchText;
        //var value = $('#searchText').val();
        //alert($('#browsers [value=&quot;' + value + '&quot;]').data('value'));
        //var x = $('#searchtextbox').val();
        //var z = $('#browsers');
        //var val = $(z).find('option[value=&quot;' + x + '&quot;]');
        //var endval = val.attr('id');
        //alert(endval);
        debugger;
        var dat = {
            &quot;courseid&quot;: localStorage.getItem(&quot;courseid&quot;)
        , &quot;USERID&quot;: USERID
        }
}
</code></pre>
<p>I need search by username and pass the USERID by fucntion or with id binding....
I tried to call it by id and passed with function its return undefined.</p>