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
source to share
No one has answered this question yet
Check out similar questions: