darylrowland / angucomplete

AngularJS Autocomplete Directive
511 stars 281 forks source link

No binding when text isn't selected #58

Closed rllola closed 9 years ago

rllola commented 9 years ago

Hi, I noticed that selectedObjects is only updated when you actualy select something from the list but it doesn't update when just type your text and click submit. Did I miss something or it is meant to be like that ?

rllola commented 9 years ago

Ok I find a solution to my problem. keyPressed function I added one magic line in angucomplete.js file to keep a synchronization between the directive and my app controller.

              $scope.keyPressed = function(event) {
                //Magic line
                $scope.selectedObject = $scope.searchStr;
                if (!(event.which == 38 || event.which == 40 || event.which == 13)) {
                .....