Thursday, September 11, 2014

angularjs How to use Custom Select

what i just tell you is this is just one of many example and
I used it

so this is one way, not a solution of using it


<div class="sel_area" style="width:40%;">
                            <button class="btn_sel" type="button"  ng-click='showDropdown()'>
                                             {{selectedCondition.name}}
                            </button><span class="caret"></span>
                            <select id='searchCondition' ng-model='selectedCondition'
                            ng-options="condition.name for condition in conditions"
                            style='opacity: 0; width:0px; float:left;' >
  <option value='이름'>이름</option>
  <option value='전화번호'>전화번호</option>
  <option value='id'>id</option>
</select></div>


$scope.conditions = [
                         {name:'이름', shade:'light'},
                         {name:'전화번호', shade:'dark'},
                         {name:'아이디', shade:'dark'}
                       ];
        
$scope.selectedCondition = $scope.conditions[0];
        
$scope.showDropdown = function () {
        var event;
        
        var element = document.getElementById('searchCondition');
        event = document.createEvent('MouseEvents');
        event.initMouseEvent('mousedown', true, true, window);
        element.dispatchEvent(event);
};

No comments:

Post a Comment