I'm trying to get some result from a custom filter with a input and a dropdwon i made. Typing in the input should be start the filter and should show the filtered results. This is the function:
$scope.filterText = "";
$scope.filterDropdown = function(textTyped) {
var searchFilter = $scope.baseUrl + "&searchStr=";
return $http.get(searchFilter + textTyped, {
cache: true
}).then(function(data) {
$scope.results = data.data.data.data;
return $scope.results;
});
};
and here the html:
<input type="text" data-ng-model-options="{ updateOn: 'default blur', debounce: {'default': 500, 'blur': 0} }"
ng-model="item.search_value" placeholder="{{item.description}}" data-ng-change="filterDropdown(filterText)"/>
<div>
<ul data-ng-repeat="descriptions in results.description">
<li>{{descriptions}}</li>
</ul>
</div>
actually i can see only a list of the entire json! I mean, when i start type the function starts but the text i type not works and the result is something like:
http://192.168.1.121:8280/test/searchStr=
where the searchStr should be fill every time i type a word. For example, i want to search : hello. I will press "h"
http://192.168.1.121:8280/test/searchStr=h
then
http://192.168.1.121:8280/test/searchStr=he
http://192.168.1.121:8280/test/searchStr=hel
http://192.168.1.121:8280/test/searchStr=hell
http://192.168.1.121:8280/test/searchStr=hello
understand? How can i fix?
You need to pass ng-model name in calling function.
data-ng-change="filterDropdown(item.search_value)
<input type="text"
data-ng-model-options="{ updateOn: 'default blur', debounce: {'default': 500, 'blur': 0} }"
ng-model="item.search_value" placeholder="{{item.description}}" data-ng-change="filterDropdown(item.search_value)"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.