Abhishek Bhalani Abhishek Bhalani - 1 month ago 10
AngularJS Question

How to get selected value of boostrap dropdown in angular?

How can I get the selected value from below dropdown.?

<ul class="nav-drop-menu" id="ddlHotelSort">
<li class="liselect" value="{{ssort.Sort}}" ng-repeat="ssort in vm.searchsort">
<a href="javascript:void(0)" class="SortClass" name="Sortclass" style="left:0px" value="{{ssort.Sort}}">{{ssort.Name}}
</a>
</li>
</ul>


Below is image of dropdown opening..
How can I handle event and model value in angular application..?

enter image description here

Answer
<ul class="nav-drop-menu" id="ddlHotelSort">
    <li class="liselect" ng-click="getSelectedItem(ssort);" value="{{ssort.Sort}}" ng-repeat="ssort in vm.searchsort">
    <a href="javascript:void(0)" class="SortClass" name="Sortclass" style="left:0px" value="{{ssort.Sort}}">{{ssort.Name}}
        </a>
    </li>
</ul>

controller function

$scope.getSelectedItem = function(item){
  console.log(item);//selected item
}