【发布时间】:2016-10-03 18:30:33
【问题描述】:
有什么方法可以忽略 ng-model 和 select item 之间的大小写?
我遇到的这个问题是 log.username 是一个输入框,而不是一个下拉列表,所以旧的用户名都有不同的大小写。
例子:
log.username = "doej";
lookupOptions.users = [{username:"DoeJ", fullName:"Joe Doe"}, {用户名:“SmithM”,全名:“MarySmith”}]
加载时选择为空而不是“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>
【问题讨论】:
-
使用 ng-repeat="option 作为 lookupOptions.users 中的选项",它有效吗?
-
不幸的是 ng-model 寻找确切的字符串值。所以,选择将是空的,否则
log.username = 'DoeJ'
标签: angularjs angular-ui-select