[英]ui-select multiple: ng-model how will it be saved as string and not as array
我有這個用戶界面選擇:
<ui-select multiple
ng-model="meas.daysSelected"
theme="bootstrap"
close-on-select="false">
<ui-select-match placeholder="days">{{$item}}</ui-select-match>
<ui-select-choices repeat="day in days | filter:$select.search">
<div ng-bind-html="day | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
$scop.days = ['Sun', 'Mon', 'Tue' ... ]
它在帶有角ng-repeat的簡單表中
<tr ng-repeat="meas in foo= (res.foos | filter: subSearch : strict)">
我用它過濾:
<input type="text" class="form-control" ng-model="subSearch.daysSelected">
問題是這樣的:當我選擇一個對象然后取消選擇它時,“ daySelected”模型將變成一個數組。 角度過濾器只是將其消除並過濾。 所以我需要以下2項之一的幫助:
假設搜索文本將類似於“ Mon,Tue”,它將過濾具有[“ Mon”,“ Tue”]的所有ui選擇,您可以編寫自己的過濾器函數並將其傳遞。 例如:
<tr ng-repeat="meas in foo= (res.foos | filter: $ctrl.filterDaysSelected">
在您的控制器中,您需要創建該函數:
$ctrl.filterDaysSelected = function(value, index, array) {}
您需要在哪里:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.