angular ui select(引导程序版本)支持optgroup吗



有人知道Angular Ui Select Bootstrap版本是否支持optgroup吗?

在上似乎找不到任何相关文档https://github.com/angular-ui/ui-select?

以下是他们的例子:

plnkr.co/edit/QCwSM75ilH2Vh6D9aMA4?p=preview

如何添加optgroup

在这个例子中,比方说,按国家对人员进行分组。

您可以使用group-by-属性。

请参阅上的"Demo Multiselect"(最后一个示例"Array of objects(with groupBy)")https://github.com/angular-ui/ui-select

这是一个多选演示,但groupby也适用于单选。

这是通过使用字符串进行分组

app.js:

$scope.countries = [
                {
                    "code": "AD",
                    "name": "Andorra",
                    "continent": "Europe"
                },
                {
                    "code": "AE",
                    "name": "United Arab Emirates",
                    "continent": "Asia"
                },
                {
                    "code": "AF",
                    "name": "Afghanistan",
                    "continent": "Asia"
                }
            ];

html:

<div>
    <label>COUNTRY</label><br>
    <ui-select ng-model="user.country" style="min-width: 300px;">
        <ui-select-match placeholder="Select Country">
            <span ng-bind="$select.selected.name"></span>
        </ui-select-match>
        <ui-select-choices repeat="country in countries | filter: {name: $select.search}" group-by="'continent'">
        <span ng-bind="country.name"></span>
        </ui-select-choices>
    </ui-select>
</div>

使用生成所有国家及其大陆的JSON

http://peric.github.io/GetCountries/

最新更新