2017-05-11 11 views
0

각도 js에서 ui.select를 사용했습니다. 선택한 여러 옵션을 성공적으로 삽입했지만 현재 업데이트 중일 때 선택한 값을 어떻게 선택합니까? ui.select에서 ng-selected를 사용했지만 작동하지 않습니다. select2에서 선택한 값을 선택하는 방법 ng-selected가있는 angularjs에서 use.select

<ui-select multiple ng-model="items.itemOptions" theme="bootstrap" 
     sortable="true" close-on-select="false"> 
<ui-select-match placeholder="Select Modules...">{{$item.module_desc}}</ui-select-match> 
<ui-select-choices repeat="itemOptions in itemOption"> 
    <div ng-bind-html="itemOption.id | highlight: $select.search" ng-selected="selectSource(itemOption.id)"></div> 
    <small> 
     {{itemOption.name}} 
    </small> 
</ui-select-choices> 
그리고 컨트롤러 내 WinFPST의 기능

$scope.selectSource = function(id) 
{ 
    console.log('id'+id); 
    var arr = $scope.selectedOptions; 
    if (arr) { 
     angular.forEach(arr, function (value, key) { 
      console.log('sel-id'+value.id); 
      if (id == value.module_id) 
       console.log('sel-opt-id'+value.id); 
      return 'selected'; 
     }); 
    } 
} 

selectedOptions 배열 =

[{id: "1"}, {id: "2"}] 

내가 각도 JS에서 ui.selct에서 옵션을 선택 보여 방법 내 질문 select2 지시문이 사용됩니다.

답변

1

심지어 비슷한 문제에 직면했지만 선택한 여러 옵션을 편집하고 싶습니다. 여러 옵션을 UI - 선택에서 작업 할 때 이 솔루션은 인 NG 모델해야 항상 첫 번째 라인을 따라 .selected

변경으로 끝나는 :

<ui-select multiple ng-model="items.itemOptions.selected" theme="bootstrap" 
     sortable="true" close-on-select="false"> 

체크 아웃은 위키입니다 : https://github.com/angular-ui/ui-select/wiki/ui-select

+0

나는 옵션을 레코드를 가져올 때 업데이트 시나리오를 사용하지 않지만 아무것도 사용하지 않습니다. 값이 사전 선택되어 선택된 상자에 표시되어야합니다. –