我使用https://github.com/angular-ui/ui-select并且我想做一些事件或一个选项,当我使用过滤器时没有找到结果时,我可以调用一个事件(打开一个模态)。
<ui-select ng-model="SelectedCustomer.selected" theme="select2">
<ui-select-match placeholder="Enter Customer">
{{$select.selected.NAME}}
</ui-select-match>
<ui-select-choices repeat="customer in Customers | filter: $select.search">
<div ng-bind-html="customer.NAME | highlight: $select.search"></div>
</ui-select-choices>
答案 0 :(得分:2)
您可以在ui选择之后在ui-select指令中添加<ui-select-no-choice>
指令,如下所示:
<ui-select multiple ng-model="something" >
<ui-select-match placeholder="something" allow-clear="true">
</ui-select-match>
<ui-select-choices>
</ui-select-choices>
<ui-select-no-choice>
This is where your code goes in. You can display some message or you can create a button too.
</ui-select-no-choice>
</ui-select>
这将按您的意愿行事。 有关参考和用法,请参阅ui-select-no-choice documentation
答案 1 :(得分:0)
只需使用ng-if为您的选项添加ui-select下方的div。像这样:
<ui-select-choices
ng-repeat="customer in filterSearch = ( Customers | $select.search)">
<div ng-bind-html="customer.NAME | highlight: $select.search"></div>
</ui-select-choices>
<div ng-if="!filterSearch"><button ng-click="openDialog()"></button></div>
您的示例中的$ search是什么?
答案 2 :(得分:0)
我在这里找到了一个解决方法https://stackoverflow.com/a/32914532/4335165,重复来自函数的结果并在on-select上处理事件。