Bootstrap 多选下拉菜单中的 AngularJS ng-repeat [英] AngularJS ng-repeat in Bootstrap multiselect dropdown

查看:17
本文介绍了Bootstrap 多选下拉菜单中的 AngularJS ng-repeat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 Bootstrap Multiselect Dropdown http://davidstutz.github.io/bootstrap-multiselect/ &嵌入到 AngularJS & 的子模板中让它使用以下函数运行:

I used Bootstrap Multiselect Dropdown http://davidstutz.github.io/bootstrap-multiselect/ & embed into the sub-template of AngularJS & let it run with the following function:

$scope.$on('$viewContentLoaded', function () {
    $(document).ready(function() {
        $('#example27').multiselect({
            includeSelectAllOption: true
        });
    });
});

我继续使用 ng-repeat 打印此输入选择的内部选项:

I continued using ng-repeat to print the inside options of this input select:

    <select id="example27" multiple="multiple">
        <option ng-repeat="list in lists" value="{{list.id}}">{{list.name}}</option>
    </select>

但是当 ng-repeat 在这个输入选择中时,它不起作用&没有打印任何数据.有谁知道怎么解决这个问题,请帮帮我!!

But when ng-repeat is in this input select, it did not work & didn't print any data. Anybody knows how to solve this problem, please help me!!

推荐答案

如果你使用 bootstrap-multiselect,你应该使用 ng-options 属性,就像@user2598687 的回答一样.这里使用 firefox 的小提琴版本:点击我进入 jsfiddle

If you use bootstrap-multiselect you should use ng-options attribute, like in @user2598687 answer. Here version of fiddle that works with firefox: click me to jsfiddle

<select class="multiselect" data-placeholder="Select Products" 
  ng-model="productSelection" ng-options="item.id as item.name for item in Products"
  multiple="multiple" multiselect-dropdown >
$scope.Products = [{id:1,name:"Apple"}, {id:2,name:"Banana"}, {id:3,name:"Carrort"}, {id:4,name:"Dart"}];

这篇关于Bootstrap 多选下拉菜单中的 AngularJS ng-repeat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆