简体   繁体   中英

Watch for current value of input with update on blur

I have following input and it updates model on blur event.

<input
  es-max-type
  class="headline"
  ng-change="edit(selectedRow, '{{selectedRow.name}}');"
  ng-model="selectedRow.name"
  ng-model-options="{ updateOn: 'blur' }"/>

es-max-type directive is watching for string length.

scope.$watch(function() {
    return scope.ngModel
}, function(text) {
    if(text) {
        scope.currentLen = text.length;
    }
});

Whenever input is focused I'm showing in corner "15/100" number of characters. But since model is updated only on blur event, I'm unable to track changes during editing. Is there a way to get string length without removing update on blur?

Try to listen "input" event. And not "change" or "blur"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM