alexandernst/angular-multi-select

selected values not getting inserted in output_data

Closed this issue · 2 comments

my html

<div class="filterControls" id="filterControls" ng-controller="ChartCtrl">
            <!--  <div ui-view name="topnav"></div>  -->
            <div style="min-width:100%; padding-top: 6px; padding-left: 6px;" ng-init="getFilterData()">
                <!-- client -->
  <div class="multiselect-wrapper jqTransformInputWrapper" id="clientFilter" style="float:left; max-width:190px; margin-left:10px;">
 <div  ng-if="showClientDropdown" style="max-width:180px;" angular-multi-select input-model="clients" output-model="output_data" dropdown-label="<[
<# angularMultiSelectConstants.INTERNAL_STATS_TOTAL_LEAFS #> === undefined ? 'SELECT CLIENT' :
<# angularMultiSelectConstants.INTERNAL_STATS_TOTAL_LEAFS #> === 0 ? 'SELECT CLIENT':
<# angularMultiSelectConstants.INTERNAL_STATS_TOTAL_LEAFS #> === null ? 'SELECT CLIENT':
<# angularMultiSelectConstants.INTERNAL_STATS_CHECKED_LEAFS #> === 0 ? 'SELECT CLIENT':     
<# angularMultiSelectConstants.INTERNAL_STATS_CHECKED_LEAFS #> === <# angularMultiSelectConstants.INTERNAL_STATS_TOTAL_LEAFS #> ? 'ALL CLIENTS': 
 <# angularMultiSelectConstants.INTERNAL_STATS_CHECKED_LEAFS #> + ' client ' + (<# angularMultiSelectConstants.INTERNAL_STATS_CHECKED_LEAFS #> === 1 ? 'selected': 'selected')]>"
  node-label="<[ text ]>" leaf-label="<[ text ]>" search-field="text" </div>
                </div>
            </div></div></div>

My Js:

$scope.clients; //storing clients received from webservice
        $scope.output_data = []; //stores all the values selected by client
//http requests to get data for filter dropdowns
        $scope.getFilterData = function() {
            //reading client count from cookie
            var ClientsCount = FetchCookieData('ClientsCount');
            //if clientcount null then don't show dropdown else show dropdown
            if (ClientsCount != '' && ClientsCount != null) {
                if (ClientsCount > 1) {
                    $scope.showClientDropdown = true;
                    //get clients
                    getFilterDataService.async("getclients").then(function(response) {
                
                            $scope.clients = response;                           
                     
                       
                    });
                }
            }

        }

Issue:
On a button click output_model returns [ ] instead of selected items.

Code looks good. Can you create a jsfiddle (or similar) demo with actual code and sample data?

Resolved the issue, ng-if="showClientDropdown" was getting reset everytime because of which I was not getting selected values/