2017-06-25 2 views
0

I AngularJS Dropdown Multiselect bin mit - http://dotansimha.github.io/angularjs-dropdown-multiselect/ das Problem, das ich bin vor ist die Option Attribut, das das Modell nichtAngularJS Dropdown Mehrfachauswahl Optionen unverbindlich

 <div style="margin: 5%" checkboxes="true" 
    ng-dropdown-multiselect="" options="example1data" selected-model="example1model"></div> 

Zum Beispiel Bindung:

wenn Modell ist:

$scope.example1model = []; 

    $scope.example1data = [ {id: 1, label: "David"}, {id: 2, label: "Jhon"}, {id: 3, label: "Danny"} ]; 

Ausgabe: die für Option Bindung s nicht richtig zu funktionieren scheint, wie ich bin nur Id bekommen (n) Rest funktioniert gut, wenn ich überprüfen, David und Johannes, die Optionen mit $ Bindung scope.example1model zeigen nur die id nicht die Label dh: [{"id":1},{"id":2} aber was ich will, ist

[ 
    { 
    "id": 1, 
    "label": "David" 
    }, 
    { 
    "id": 2, 
    "label": "John" 
    } 
] 

Antwort

0

Sie wie unten versuchen.

\t <!DOCTYPE html> 
 
\t <html> 
 
\t <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> 
 
\t <body> 
 

 
\t <div ng-app ="sortApp" ng-controller ="mainController"> 
 
\t \t \t \t \t <!DOCTYPE html> 
 
<html lang="eng-US"> 
 
\t <head> 
 
\t \t <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> 
 
\t </head> 
 
\t <body> 
 
\t  <select class="multiselect" data-placeholder="Select Products" 
 
     ng-model="example1model" ng-options="item as item.label for item in example1data" 
 
     multiple="multiple" multiselect-dropdown > 
 
    </select> 
 
\t {{example1model}} 
 
\t \t <div style="margin: 5%" checkboxes="true" ng-dropdown-multiselect="" options="example1data" selected-model="example1model"></div> 
 
\t </body> 
 
</html> 
 
\t \t \t \t </div> 
 
\t <script> 
 
\t angular.module('sortApp', []) 
 

 
\t .controller('mainController', function($scope) { 
 
\t $scope.example1model = []; 
 

 
    $scope.example1data = [ {id: 1, label: "David"}, {id: 2, label: "Jhon"}, {id: 3, label: "Danny"} ]; 
 
\t 
 
\t }); 
 
\t </script> 
 

 
\t </body> 
 
\t </html>

0

Set externalIdProp als leere Zeichenfolge

$scope.extraSettings = { 
    externalIdProp: '' 
    }; 

html

<div ng-dropdown-multiselect="" options="options" selected-model="myModel" extra-settings="extraSettings"></div> 

Works für mich, ich bin mit ^1.11.8

Verwandte Themen