I am new to angular js and using the xmpp service with angular js, I have a situation where I need to send input when the user starts typing in the input field and pause when the user stops typing.
I have a basic idea that I need to use $ timeout and have one variable of type vm.isTyping = false;
I also wrote some platform for the same.
vm.isTyping = false; vm.checkTyping = function(){ $timeout(function() { vm.isTyping = true; },2000); if(!vm.isTyping){ vm.sendTyping(); } else{
This is the input field code:
<input type="text" placeHolder="Type a message here" ng-model="vm.newMessage" ng-blur="focusRemove(vm.newMessage,vm.contact)" ng-change="vm.checkTyping()" ng-model-options="{'debounce': 500}" ng-keydown="vm.onKeyDown($event)" auto-focus />
The problem that I am facing is that I cannot send typing every time the user presses any key, one input is sent the first time the key is pressed, then I have to pause when the user stops typing.
Can someone help me implement the code in angular js to achieve this.
source share