2

In my angular application , I have created one dropdown containing sim name. Those names are coming from API. I also set default value as All sim. But it is not working. Here is my code snippet.

<select ng-model="selectSim" class="selectpicker" ng-options=" item.description for item in simList">
<option value="all">Select All</option>

When I I render this page , I can see dropdown containing Sim name but my "select all" option is missing.

I cant figure it out whats wrong in my code.

1
  • Can you show me your controller code????????? Commented Jun 4, 2014 at 8:55

2 Answers 2

2

Set option value = ""

<select ng-model="selectSim" class="selectpicker" ng-options=" item.description for item in simList">
      <option value="">Select All</option>
</select>

A single hard-coded element, with the value set to an empty string, can be nested into the element. This element will then represent the null or "not selected" option.

Sign up to request clarification or add additional context in comments.

Comments

0

try this

This is html code (don't need option tag )

<select ng-model="selectSim" class="selectpicker" ng-options=" item.description for item in simList">

and write this way in your controller code where assign values to simList

$scope.simList.push({ description : "Select All", Id: 0 }); // this line helps to dynamoically add defualt value in `$scope.simList` array, now the default item added in bottom side 

  $scope.selectSim= $scope.simList[$scope.simList.length - 1];// this is helps to assign default item `selectSim` model 

'*' here Id: 0 is your value name and dummy values. you need to change value name

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.