【问题标题】:How to call function inside ui select tag where input is changed如何在输入更改的ui选择标签内调用函数
【发布时间】:2015-11-26 16:14:31
【问题描述】:
<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+'*')"

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

【问题讨论】:

    标签: angularjs ui-select


    【解决方案1】:

    使用 ngInit 获取值

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

    【讨论】:

      猜你喜欢
      • 2011-09-03
      • 1970-01-01
      • 2020-06-13
      • 2014-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多