2017-04-04 203 views
2

我用數據填充從Web API來一個選擇多,但我想顯示另一個查詢所選的值,它不工作Angularjs選擇多個選項不工作

型號

$scope.clickevent = function (id, name) { 
    $scope.id = id 

    $scope.fleetFeatures = fleetFeatures.list; 

    $http.get(myUrl + "FleetFeatures/Selected?id_fleet=" + $scope.id).then(function (data) { 
     $scope.selectedFeatures = data.data; 
    }); 
} 

查看

 <div class="input-field col s12"> 
      <select class="" id="features" ng-model="selectedFeatures" ng-options="item.FleetFeatureId as item.FleetFeatureName for item in fleetFeatures" multiple material-select watch> 
        <option value="" disabled selected>{{translation.fleet5}}</option> 
       </select> 
     </div> 

fleetFeatures

[{"$id":"1","Fleet_FleetFeatures":[],"FleetFeatureId":1,"FleetFeatureName":"Advanced Geocoding Features","FleetFeatureCode":1,"FleetFeatureData":null},{"$id":"2","Fleet_FleetFeatures":[],"FleetFeatureId":2,"FleetFeatureName":"feature 2","FleetFeatureCode":2,"FleetFeatureData":null},{"$id":"3","Fleet_FleetFeatures":[],"FleetFeatureId":3,"FleetFeatureName":"feature 3","FleetFeatureCode":672,"FleetFeatureData":null}] 

selectedFeatures

[{"$id":"1","FleetFeatureId":3},{"$id":"2","FleetFeatureId":1}] 

我缺少的代碼什麼的,因爲我選擇加載它,但它並沒有顯示我選擇

感謝任何提前

回答

2

因爲你已經掠FleetFeatureId而不是整個項目做item.FleetFeatureId as item.FleetFeatureName。你應該指定selectedFeatures應該像下面那樣

[3, 1] 
+1

=)...你一直很快。 – lin