1
<input 
  data-id={{field.id}} 
  type="text" 
  ng-model="add[field.id]" 
  typeahead="item for item in {{field.function}}($viewValue+'*')" 
  class="form-control" 
  typeahead-select-on-exact="true"
  ng-if="field.function" 
  typeahead-editable="false" 
  typeahead-select-on-blur="true"
  ng-pattern="field.validate.pattern?field.validate.pattern:''"  
  maxlength="{{field.validate.maxlength?field.validate.maxlength:''}}"
  minlength="{{field.validate.minlength?field.validate.minlength:''}}"
  required>

我想通过使用 ui-select 而不是预先输入来更改此输入标记。我试过了

 <ui-select 
  ng-if="field.function"
  ng-model="add[field.id]" 
  theme="selectize" 
  ng-disabled="disabled" 
  style="width: 300px;">
    <ui-select-match>{{$select.selected}}</ui-select-match>
    <ui-select-choices repeat="item for item in {{field.function}}($select.search +'*')"> 
    </ui-select-choices>
</ui-select>

我无法转换

typeahead="item for item in {{field.function}}($viewValue+'*')"

在这里,我正在调用一个函数,该函数根据输入的返回值。

4

1 回答 1

0

使用 ngInit 获取值

<div ui-select ng-init="vm.$select = $select"></div>
<button ng-click="vm.search(vm.$select.search)">Search</button>
于 2015-11-26T08:14:31.500 回答