I search through large data using AngularJS only when I type >3 chars in input.
var app = angular.module('test_table', []);
app.controller('main_control',function($scope, $http){
$scope.inputChange = function(){
if($scope.search.length > 3){
$http.get("http://localhost:7001/load").success(function(data){
$scope.loaded=data;
});
}
if($scope.search.length < 4){
$http.get("http://localhost:7001/load").success(function(data){
$scope.loaded="";
});
}
}
});
HTML code:
<input type="search" class="inputsearchform" ng-model="search" ng-change="inputChange()"/>
...
<tr class="rowR" ng-repeat="data in loaded | filter:{song_name: search}">
I have problem. When I type more than 3 chars and then delete everything using default button in input, the whole data is loaded to the page, and it cause a big delay. How to deal with it?