2017-09-27 75 views
0

對於我來說,靜態選項標籤對於多選選項工作正常,但如果使用ng-repeat,我沒有獲得選項列表,如果我刪除「選擇選擇」列表即將到來。 以下工作正常ng-repeat對於選擇選項不起作用

in JS 
    var config = { 
          '.chosen-select'   : {}, 
          '.chosen-select-deselect' : { allow_single_deselect: true }, 
          '.chosen-select-no-single' : { disable_search_threshold: 10 }, 
          '.chosen-select-no-results': { no_results_text: 'Oops, nothing found!' }, 
          '.chosen-select-rtl'  : { rtl: true }, 
          '.chosen-select-width'  : { width: '95%' } 
         } 
         for (var selector in config) { 
          $(selector).chosen(config[selector]); 
         } 
     } 
In Html 
    <select data-placeholder="Choose a Country..." class="chosen-select" multiple tabindex="4">  
       <option value="United States">United States</option> 
       <option value="United States">India </option> 
       </select> 

如果我換成這個網站碼NG-重複它無法正常工作。

<select data-placeholder="Choose a Group" class="chosen-select" multiple tabindex="4">  
      <option ng-repeat="x in group" value="{{x.groupId}}">{{x.groupName}}</option> 
      </select> 

我也使用chosen.jquery.js文件。

+0

你加入[角揀選](https://github.com/leocaseiro/angular-chosen)和在組「g」中嘗試過'ng-options =「g.groupId作爲g.groupName,你必須使用'ngModel'指令? – Satpal

+0

@Satpal我已包括Angular Chosen現在它工作正常,但我必須按住Ctrl鍵mulitiselect – Sudhir

+0

Sudhir

回答

1

添加角chosen.min.js和列表(類別)是數組值

<select chosen multiple tabindex="4" class="form-control" ng-model="categoryid" ng-options="cat for cat in category" id="category" >  
    <option value=""></option> 
</select> 
+0

Sudhir

+0

但我要按住ctrl並選擇多個選擇 – Sudhir

+0

使用angularChosen後,將其工作 – Sudhir