有没有办法将自定义按钮添加到角度TypeAhead指令?

时间:2016-12-01 17:10:43

标签: angularjs typeahead.js typeahead bootstrap-typeahead

我目前正在使用预先输入指令组件,该组件工作正常但缺少某些功能。该组件通过查询获取所有需要的数据,该查询在加载页面后立即触发并选择预定义的默认条目。但是总有至少15个条目可用,但为了在同一个下拉列表中创建新记录,我想添加一个"创建按钮"在搜索列表的末尾。因此,如果用户键入任何字符串并且在下拉列表中不可用,则他/她可以通过该按钮创建记录。有没有办法创建一个自定义版本的打字稿,我可以添加一个按钮来保存在文本框中输入的记录?

<h4>Custom popup templates for typeahead's dropdown</h4>
<pre>Model: {{customPopupSelected | json}}</pre>
<input type="text" ng-model="customPopupSelected" placeholder="Custom popup template" uib-typeahead="state as state.name for state in statesWithFlags | filter:{name:$viewValue}" typeahead-popup-template-url="customPopupTemplate.html" class="form-control">


<script type="text/ng-template" id="customPopupTemplate.html">
<div class="custom-popup-wrapper"
 ng-style="{top: position().top+'px', left: position().left+'px'}"
 style="display: block;"
 ng-show="isOpen() && !moveInProgress"
 aria-hidden="{{!isOpen()}}">
<p class="message">select location from drop down.</p>

<ul class="dropdown-menu" role="listbox">
  <li class="uib-typeahead-match" ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }"
    ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)" role="option" id="{{::match.id}}">
    <div uib-typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
  </li>
</ul>

0 个答案:

没有答案