I'm using ui-select (https://github.com/angular-ui/ui-select).
ui-select support us to Search, Select, and Multi-select. But how can I get the value users typed in ui-select search box? I want to display an error message if the value users typed is not correct.
Example: In this plunker below with Select2 theme, when the user type: 'asdasd' (this text does not match with any results) I want display a message "Do not find any results!" by assigning to 'scope.person.selected'
plnkr.co/edit/a3KlK8dKH3wwiiksDSn2?p=preview
How can I do that?
Thanks so much!
The input data in angular_ui_select goes into the $select.search model
.
You could use refresh attribute of ui-select-choice
.
Just pass the function in refresh="test($select.search)"
,and set delay and min input length using refresh-delay
and minimum-input-length
attributes respectively.
here is an quick example:
<ui-select ng-model="model" theme="theme">
<ui-select-match>{{data}}</ui-select-match>
<ui-select-choices repeat="options in data" refresh="yourFunction($select.search)" refresh-delay="100" minimum-input-length="1"></ui-select-choices>
</ui-select>
I would suggest you go through the documentation, hope it would help. angular-ui-select
You can use ng-keypress="fn($select.search)" at <ui-select...>
And use this function at controller to get the input.
$scope.fn = function(search) {
//do something with search
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With