UI-Select 不区分大小写
UI-Select case Insensitive
有什么方法可以忽略 ng-model 和 select item 之间的大小写吗?
我遇到的这个问题是 log.username 是一个输入框而不是一个下拉列表,所以旧用户名的大小写都不同。
Example:
log.username = "doej";
lookupOptions.users = [{username:"DoeJ", fullName:"Joe Doe"},
{username:"SmithM", fullName:"MarySmith"}]
On load select is empty instead of having "DoeJ"
<div class="form-group col-md-4">
<label>Stored By</label>
<ui-select ng-model="log.username" theme="bootstrap">
<ui-select-match placeholder="Select Site">{{$select.selected.username}}</ui-select-match>
<ui-select-choices repeat="option.username as option in lookupOptions.users | orderBy: 'username' | propsFilter: {'username': $select.search}">
<div ng-bind-html="option.username | highlight: $select.search"></div>
<small ng-bind-html="option.fullName | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
</div>
这就是我所做的:
控制器:
log.username = log.username ? log.username.toLowerCase() : "";
查看:
<div class="form-group col-md-4">
<label>Stored By</label>
<ui-select ng-model="log.username" theme="bootstrap">
<ui-select-match placeholder="Select Site">{{$select.selected.username}}</ui-select-match>
<ui-select-choices repeat="option.username.toLowerCase() as option in lookupOptions.users | orderBy: 'username' | propsFilter: {'username': $select.search}">
<div ng-bind-html="option.username | highlight: $select.search"></div>
<small ng-bind-html="option.fullName | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
</div>
有什么方法可以忽略 ng-model 和 select item 之间的大小写吗?
我遇到的这个问题是 log.username 是一个输入框而不是一个下拉列表,所以旧用户名的大小写都不同。
Example:
log.username = "doej";
lookupOptions.users = [{username:"DoeJ", fullName:"Joe Doe"}, {username:"SmithM", fullName:"MarySmith"}]
On load select is empty instead of having "DoeJ"
<div class="form-group col-md-4">
<label>Stored By</label>
<ui-select ng-model="log.username" theme="bootstrap">
<ui-select-match placeholder="Select Site">{{$select.selected.username}}</ui-select-match>
<ui-select-choices repeat="option.username as option in lookupOptions.users | orderBy: 'username' | propsFilter: {'username': $select.search}">
<div ng-bind-html="option.username | highlight: $select.search"></div>
<small ng-bind-html="option.fullName | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
</div>
这就是我所做的:
控制器:
log.username = log.username ? log.username.toLowerCase() : "";
查看:
<div class="form-group col-md-4">
<label>Stored By</label>
<ui-select ng-model="log.username" theme="bootstrap">
<ui-select-match placeholder="Select Site">{{$select.selected.username}}</ui-select-match>
<ui-select-choices repeat="option.username.toLowerCase() as option in lookupOptions.users | orderBy: 'username' | propsFilter: {'username': $select.search}">
<div ng-bind-html="option.username | highlight: $select.search"></div>
<small ng-bind-html="option.fullName | highlight: $select.search"></small>
</ui-select-choices>
</ui-select>
</div>