javascriptangularjsangular-strap

bs-select (angular-strap) dropdown open by default when page load


I am using the plugin provided from github.

How can I default open the dropdown when page loads?

I tried different options like bs-show="true" then get Id of the select and add click event, but nothing seems to be working.

<span class="text-bold" id="godVar">
            SLA
            <button type="button" class="btn btn-default btn-sm" ng-model="model"
            ng-change=""
            data-html="1" data-multiple="1" placeholder="Select SLA" bs-show="true"
            bs-options="type for type in ::filters" max-length=1 bs-select id="test">
                <span class="caret"></span>
            </button>
        </span>

$scope.test= angular.element("#test");
$scope.test.click();

Solution

  • Use

    $timeout(function() {
       angular.element('#test').trigger('mousedown')
    }, 0);
    

    this solution requires jQuery included, but since you are using click() you have included that already.

    here is a demo -> http://plnkr.co/edit/ScHtNPYksBXx3RqM8sCT?p=preview