简体   繁体   中英

How to preselect a option - Dropdown

my HTML is a static variant, not a solution builded with ng-repeat or an existing JSON/Angular Controler.

I need to select a custom option and used alreay ng-select without a success.

My HTML looks like:

        <div class="btn-group" dropdown>
        <button type="button" class="pull-right btn btn-block btn-dropdown" dropdown-toggle>
            <div class="pull-left">
                <i class="flag-{{my.filter.flag}} left vcenter"></i>
                <span class="vcenter">{{my.filter}}</span>
            </div>
            <div class="pull-right"><span class="caret"></span></div>
        </button>
        <ul class="dropdown-menu" dropdown-menu ng-init="options[0]">
            <li ng-class="{active: my.filter == 'Germany'}">
                <a ng-click="my.filter = 'Germany'; my.filter.flag='DEU'"><i class="flag-DEU"></i><span>Germany</span></a>
            </li>
            <li ng-class="{active: my.filter == 'England'}">
                <a ng-click="my.filter = 'England'; my.filter.flag='GBP'"><i class="flag-GBP"></i><span>England</span></a>
            </li>
        </ul>
    </div>

so how can i solve it to preselect the option "Germany" by pageloading into the div.pull-left section?

You mention ng-select in your question, but you used ng-selected. Maybe it is just a typo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM