arun
arun

Reputation: 145

Search functionality using multiple select option - angularjs

Now I am working in an search functionality module using angularjs, search functionality is implemented by multiple select options, user can select more than one option in select tag, it's not a problem, but I am facing issue to load the saved search details into the select tag,(have to show pre-selected search data into the select tag)

<select name="" ng-model="sex" multiple ng-options="sex.name as sex.name for sex in choosesex">
</select>

which displays the list like Male and Female like below,

$scope.choosesex = [{ID:1,name:"Male"},
                  {ID:2,name:"Female"}];

I have get the json response from saved search, while pushing the result into the ng-model it doesnot show the selected option in select tag, Please share your opinions regarding this issue to fix. Thanks in advance.

Upvotes: 0

Views: 54

Answers (1)

Joe
Joe

Reputation: 2540

sex.name as sex.name is not right. Try this:

<select name="" ng-model="sex" multiple ng-options="sex as sex.name for sex in choosesex"></select>

Upvotes: 1

Related Questions