如何在ui选择标签中调用函数,其中输入发生了变化


<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+'*')"

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

使用ngInit获取值

<div ui-select ng-init="vm.$select = $select"></div>
<button ng-click="vm.search(vm.$select.search)">Search</button>

相关内容

  • 没有找到相关文章

最新更新