0

My app makes use of socketio to push changes in a textarea to all connected clients. When a user types in the textarea I want two things to happen:

1) Push the text via the socket immediately

2) Save the text to the DB after each change with a 1 second debounce

I've tried this but it won't push or save for some reason:

<div ng-model="text" ng-keyup="push()" ng-change="save()" ng-model-options="{ debounce: 1000 }"></div>

I've also tried this from the docs:

ng-model-options="{ updateOn: 'change', debounce: {'change': 1000} }"

but still no luck. Any help would be much appreciated.

tommyd456
  • 10,443
  • 26
  • 89
  • 163

1 Answers1

0

div doesn't throw an onchange event. You should be using an <input> element. Otherwise, you'll have to identify when the contents change and manually call save().

See:
https://stackoverflow.com/a/6676218/413397
https://docs.angularjs.org/api/ng/directive/ngChange

Community
  • 1
  • 1
Tony
  • 2,473
  • 1
  • 21
  • 34