Я пытаюсь получить какой-то результат от пользовательского фильтра с помощью ввода и созданного dropdwon. Ввод на вход должен начинаться с фильтра и показывать результаты фильтрации. Это функция:
$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;
});
};
и здесь 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>
на самом деле я могу видеть только список всего json! Я имею в виду, когда я запускаю тип, функция запускается, но текст типа я не работает, и результат выглядит примерно так:
http://192.168.1.121:8280/test/searchStr=
где searchStr должен заполняться каждый раз, когда я набираю слово. Например, я хочу найти: hello. Я нажму "h"
http://192.168.1.121:8280/test/searchStr=h
тогда
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
Понимаю? Как я могу исправить?
Вы должны передать имя ng-модели в вызывающей функции.
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)"/>