darylrowland / angucomplete

AngularJS Autocomplete Directive
511 stars 281 forks source link

On Blur (On Change) action #125

Open mhipo1364 opened 8 years ago

mhipo1364 commented 8 years ago

Hi guys

Is there any event listener about blur or change action in input?

milad1367 commented 6 years ago

add this "onBlur": "&" to scope. add onBlur to selectResult:

            vm.selectResult = function(result) {
                if (vm.matchClass) {
                    result.title = result.title.toString().replace(/(<([^>]+)>)/ig, '');
                }
                vm.searchStr = vm.lastSearchTerm = result.title;
               // vm.selectedObject = result;
                vm.selectedObject = result.originalObject;
                vm.onBlur({user:result.originalObject});
                vm.searchStr = "";
                vm.showDropdown = false;
                vm.results = [];
                //$scope.$apply();
            }

and this :

 <ibd-autocomplete-input id="{{vm.unicId}}"
                            placeholder="{{vm.unicId}}"
                            pause="100"
                            selectedobject="vm.input"
                            localdata="vm.allUsers"
                            searchfields="username"
                            titlefield="username"
                            minlength="1"
                            imagefield="pic"
                            inputclass="form-control form-control-small"
                            on-blur = "vm.addUser(user)"
                            />