Angularjs ui选择多个:ng模型如何将其保存为字符串而不是数组
我选择了以下ui:Angularjs ui选择多个:ng模型如何将其保存为字符串而不是数组,angularjs,ui-select,angular-ui-select,Angularjs,Ui Select,Angular Ui Select,我选择了以下ui: <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 | fi
<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' ... ]
{{$item}}
$scop.days=['Sun'、'Mon'、'Tue'…]
它是在一个简单的表中,带有角度ng重复
<tr ng-repeat="meas in foo= (res.foos | filter: subSearch : strict)">
我用以下方法对其进行过滤:
<input type="text" class="form-control" ng-model="subSearch.daysSelected">
问题是这样的:“daySelected”模型在我选择一个对象然后取消选择它时变成了一个数组。angular的过滤器只是将其删除并过滤。
因此,我需要以下两个方面的帮助:
假设搜索文本类似于“Mon,Tue”,它将过滤所有具有[“Mon”,“Tue”]的ui选择,您可以编写自己的过滤函数并传递该函数。例如:
<tr ng-repeat="meas in foo= (res.foos | filter: $ctrl.filterDaysSelected">
您需要:
- 将搜索条件的值除以“,”
- 验证分割数组中的每个项是否存在于函数值参数中
$ctrl.filterDaysSelected = function(value, index, array) {}