Reputation: 3638
So I created a dropdown like the following:
<select style="width: 100%" ng-model="selectPosition" ng-Change="GetPosition(selectPosition)">
<option value="Partner">Partner</option>
<option value="Associate">Associate</option>
<option value="Council">Council</option>
</select>
In my controller, I make the option from the dropdown selected depending on the data. Now I want to check if the data exist in that dropdown. How do I do that?
$scope.selectPosition = $scope.Data.CompanyTitle;
Upvotes: 1
Views: 537
Reputation: 649
If you want to do this using angularjs than you have to use ng-options to check whether or not there is data in "select".
or your can do like this also in your controller.
document.getElementsByTagName('select')[0].children.length
or document.getElementById('select')[0].children.length
hope this helps you
Upvotes: 1
Reputation: 1102
Make your options using ng-options
<select ng-options="item as item.label for item in selectOptions track by item.id" ng-model="selectPosition"></select>
Then you will be able to loop through selectOptions and check.
Upvotes: 1