2017-02-28 47 views
0

我有一個用戶對象,我想編輯,單擊編輯按鈕幾個表格值正在加載,但三個值沒有得到填充。我從服務檢查我收到的數據,但它不是填充。Dropdown值沒有使用角度js填充

HTML

<div class="col-xs-4 col-sm-4 col-md-3 col-lg-3 label-right"> 
     <label class="control-label">{{::'label.country'|translate}}</label> 
     <label class="asterisk">*</label> 
    </div> 
    <div class="col-xs-8 col-sm-8 col-md-9 col-lg-9 controls"> 
     <select id="selectCountry" name="selectCountry" required ui-select2="select2CountrySettings" ng-model="selectedUser.country"> 
      <option ng-repeat="country in countryList" value="{{country.name}}" ng-selected="{{country.name == selectedUser.country}}">{{country.name}}</option> 
     </select> 
     <span class="help-block" ng-show="editUserForm.selectCountry.$dirty && editUserForm.selectCountry.$error.required">{{::'error.required'|translate}}</span> 
    </div> 
</div> 

<!-- Locale --> 
<div class="row control-group" ng-class="{error:editUserForm.selectLocale.$dirty && !editUserForm.selectLocale.$valid, success:editUserForm.selectLocale.$valid}"> 

    <div class="col-xs-4 col-sm-4 col-md-3 col-lg-3 label-right"> 
     <label class="control-label">{{::'label.user.locale'|translate}}</label> 
     <label class="asterisk">*</label> 
    </div> 
    <div class="col-xs-7 col-sm-7 col-md-9 col-lg-9 controls"> 
     <select id="selectLocale" name="selectLocale" required class="locale-select" ui-select2="select2LocaleSettings" ng-model="selectedUser.culture"> 
      <option ng-repeat="locale in localeList" value="{{locale.name}}" ng-selected="{{locale.name == selectedUser.culture}}">{{locale.name}}</option> 
     </select> 
     <span class="help-block" ng-show="editUserForm.selectLocale.$dirty && editUserForm.selectLocale.$error.required">{{::'error.required'|translate}}</span> 
    </div> 
</div> 

的Javascript

function reloadUser() { 
    loadingDataBegin(); 

    userDetails.getUserById(userDetails.getSelectedUser().id).then(function (response) { 
     $scope.selectedUser = response.results; 
    }, function (error) { 
     if (error.status !== undefined && (error.status === 401 || error.status === 403)) { 
      $rootScope.authentication.reAuthenticate(); 
     } else { 
      toasty.generalError(); 
     } 
    }); 
} 

$scope.selectedUser我從服務最後三個下拉菜單語言環境,國家和組織是沒有得到填充在下拉(image)讓所有的值。

+0

您是否只能包含代碼的**相關**部分,而不是100行HTML代碼? – Mistalis

+0

也許您返回的數據與您在選擇列表中設置的值不同? – Jorrex

回答

0
  1. 使用NG選項它會讓你所選的項目,選擇框

如何使用它

ng-options="item.id as item.name for item in names" 
  • 使用NG-如果將值分配給相應的型號
  • +0

    我得到了答案,我的數據在解決承諾之前就已經被填充了。 –