如何在多个UI选择角js中禁用默认值

问题描述:

我在我的页面上有多个ui-select控件,用户从下拉列表中选择用户组,我希望在控件中首先选择的选项被禁用,用户不能删除自己的组。如何在多个UI选择角js中禁用默认值

我的代码看起来象

<tr ng-repeat="item in UserGroups"> 
    <ui-select multiple 
         class="col-md-8 input-sm" 
         ng-model="item.selectedUserGroup" 
         theme="bootstrap"> 
       <ui-select-match placeholder="Select field...">{{$item.group_name}}</ui-select-match> 
       <ui-select-choices 
         repeat="grp in AccessGroups | filter:$select.search"> 
        <div ng-bind-html="grp.group_name | highlight: $select.search"></div> 
       </ui-select-choices> 
      </ui-select></tr> 

其中AccessGroups是一个对象

$scope.AccessGroups = [ 
     {group_id: "1", group_name: "Portfolio Manager"}, 
    {group_id: "2", group_name: "Risk Manager"}, 
    {group_id: "3", group_name: "Analyst"}, 
    {group_id: "4", group_name: "Operations"}] 

和整个UI的选择被放置在NG-重复 其中一个一个像

$scope.UserGroups = [ 
       {benchmark_id:"38", 
       benchmark_name:"Test ", 
       group_name:"5,1", 
       selectedUserGroup:Array(2)[{group_id: "5", 
              group_name: "Administrator"}, 
              {group_id: "1", 
              group_name: "Portfolio Manager"}] 
       }] 

可以你们帮我我卡在这个point.i已尝试删除X标志f rom UI的工作,但我不能在程序上做到这一点。 请看图像以获得想法。 picture having view of control on the page

+0

为什么你会不会,而不是完全删除该选项?这似乎是一个用户界面分心,让它在那里。 – isherwood

+0

实际上我不需要将默认组显示为已选中,但用户需要删除其自己的组 – Rajat

我不知道它是否可以作为解决我技术上的问题,但它为我工作。 我只需从css选择器的帮助下从选定值的第一个条目中删除交叉符号,这样可以防止用户删除自己的用户组。

我用这个CSS Selecter删除交叉迹象

#benchmarkCreated > div:nth-child(1) > table > tbody > tr> td:nth-child(3) > div > div:nth-child(1) > span > span:nth-child(1) > span > span.close.ui-select-match-close{ 
    display: none; 
}