I need a help. i was trying to keep track of user clicks. The scenario is, i have list on which user can perform a click, on click a call to server has been made to fetch data. But i get stuck in situation, if user simultaneously click on list, multiple request reached to server.
What i want is only click call will happen and request to server for data.
Here what i've done till now.
function getData(id) {
_this.lastClickId = _this.currentId;
dataFactory.getListOfData(id).then(function(response) {
if(_.isEqual(_this.lastClickId , id)){
appendData(response);
} else {
getData(executionId);
}
});
_this.currentId = id;
}
here is my html code:
<ul>
<li ng-click="getData(1)">option1</li>
<li ng-click="getData(2)">option2</li>
</ul>