如何从ng-dropdown-multiselect访问所选项目的属性?

时间:2018-07-13 10:39:33

标签: angularjs dropdown ng-dropdown-multiselect

我正在使用angular的ng-dropdown-multiselect,并且看到每次选择一个项目时,只会将其ID添加到模型中。我想将所选项目添加到列表中,我需要访问该列表的其他属性。我在这里做错什么了吗?

Dropdown: <div ng-dropdown-multiselect="" options="example9data" selected-model="example9model" extra-settings="example9settings" events="yourEvents"></div>
    <br/>
    Model: {{example9model}}

JS:

$scope.example9model = []; 
        $scope.example9data = [ {id: 1, label: "David"}, {id: 2, label: "John"}, {id: 3, label: "Danny"}]; 
        $scope.example9settings = {enableSearch: true, keyboardControls: true, clearSearchOnClose: true, template: '{{option.label}}',
        smartButtonTextConverter(skip, option) { return option.label; }};
        $scope.list = [];

        $scope.yourEvents = {
            onItemSelect: function(item) {
                     console.log(item);
                },
            onItemDeselect: function(item) {
                     console.log(item);
               }
        };

0 个答案:

没有答案