Angular UI type model changed

I have a strange situation with ui typeahead. For some reason, when results come in, the ng-model is changed to the first result of the results. This is a problem for me because I have an on-enter event in which I need to use the value from the input.

Here is the HTML:

<input type="search" dropdown-toggle
                               class="form-control input--search"
                               pw-enter="searchEnter()"
                               placeholder="Search"
                               typeahead="result.text for result in getSearchResult($viewValue)"
                               ng-model="search.query"
                               typeahead-template-url="views/search-custom.html"
                               typeahead-wait-ms="300"
                               typeahead-focus-first="false"
                               >

      

code:

$scope.getSearchResult = function (query) {
            return SearchService.getResults(query);
        };

$scope.searchEnter = function(){
            $location.path('/advance-search').search({query : $scope.search.query});
        };

      

As you can see, this is a search and on-enter implementation. I need to go to the search query ( $ scope.search.query ), but for some reason the value changes to the first result in the results I mentioned.

How can I fix this or is there any workaround?

+3
javascript angularjs angularjs-directive angular-ui


source to share


No one has answered this question yet

Check out similar questions:

2614
How do I change the class of an element using JavaScript?
1006
What is the difference between angular-route and angular-ui-router?
432
Angular directives - when and how to use compilation, controller, pre-link and post-link
8
AngularJS [typeahead] pops up onFocus bubble results
1
Select value after blur with bootstrap typeahead
1
Two functions - one for blur, and one when the model changes in the angular input box
1
Angular Typeahead UI - Disable Dropdown
1
Angular JS UI Bootstrap Typeahead
0
angled bootstrap typeahead close select
0
Angular-ui Bootstrap type control and ng-keydown



All Articles
Loading...
X
Show
Funny
Dev
Pics