I would like to do http Get on every textfield particularly in my HTML ..
I need sending http GET when user typing something in actually focused textfield ..and in backend is making realtime searching DB for result (i ve got that function which use req.body for query text searching in mongo)...if searching text match something with DB it should show image from DB over textfield ..If I make it only for one textfield it should work...but do not know how to make it in some cycle or what ..without making GET method for every extra single textfield ..In future i would like to have dynamically raising textfields count when user pressed space and it create new empty input field.. My HTML should look like for beginin like :
<div class="container">
<br>
<div class="row">
<div class="col-sm-2 col-lg-2 col-xs-2">
<img data-ng-src="data:image/png;base64,{{data}}" width="100%"/>
<br>
<h1 style="color:#258cd1;"><input type="text" ng- model="userInput.search" class="text-center" style="border-width: 0px ;width:100%" > </h1>
</div>
<div class="col-sm-2 col-lg-2 col-xs-2">
<img data-ng-src="data:image/png;base64,{{data2}}" width="100%"/>
<br>
<h1 style="color:#258cd1;"> <input type="text" ng-model="userInput.search2" class="text-center" style="border-width: 0px ;width:99%"></h1>
</div>
<div class="col-sm-2 col-lg-2 col-xs-2">
<img data-ng-src="data:image/png;base64,{{data3}}" width="100%"/>
<br>
<h1 style="color:#d62c1a;"> <input type="text" ng-model="userInput.search3" class="text-center" style="border-width: 0px ;width:99%"></h1>
</div>
<div class="col-sm-2 col-lg-2 col-xs-2">
<img data-ng-src="data:image/png;base64,{{data4}}" width="100%"/>
<br>
<h1 style="color:#258cd1;"> <input type="text" ng-model="userInput.search4" class="text-center" style="border-width: 0px ;width:99%"></h1>
</div>
<div class="col-sm-2 col-lg-2 col-xs-2">
<img data-ng-src="data:image/png;base64,{{data4}}" width="100%"/>
<br>
<h1 style="color:#d62c1a;"> <input type="text" ng-model="userInput.search9" class="text-center" style="border-width: 0px ;width:99%"></h1>
</div>
<div class="col-sm-2 col-lg-2 col-xs-2">
<img data-ng-src="data:image/png;base64,{{data4}}" width="100%"/>
<br>
<h1 style="color:#258cd1;"> <input type="text" ng-model="userInput.search5" class="text-center" style="border-width: 0px ;width:99%"></h1>
</div>
</div>
and in controller I ve got something like this ..but it works only for one field..
$scope.$watch('userInput.search', function () {
$http({
url: '/imgskuska',
method: 'POST',
headers: {'Content-Type': 'application/json'},
data: $scope.userInput
}).success(function (response) {
$scope.data = response;
})
})
What I need to do is call GET method (post is not good idea I think) with $scope.$watch in controller only on that textfield which is actually focused ..and user is typing in that something ..when the user focused on another textfield with tabKey make call from another input .. I need some advices how to do it ....thanks a lot ..