【问题标题】:Watch for current value of input with update on blur通过模糊更新观察当前输入值
【发布时间】:2015-08-19 09:40:13
【问题描述】:

我有以下输入,它会根据模糊事件更新模型。

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

es-max-type 指令正在监视字符串长度。

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

每当输入被聚焦时,我都会在角落显示“15/100”个字符。但由于模型仅在模糊事件时更新,我无法在编辑期间跟踪更改。有没有办法在不删除模糊更新的情况下获取字符串长度?

【问题讨论】:

标签: javascript angularjs jqlite


【解决方案1】:

尝试监听“输入”事件。而不是“改变”或“模糊”

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-19
    • 1970-01-01
    • 2018-09-24
    • 1970-01-01
    • 1970-01-01
    • 2013-01-10
    相关资源
    最近更新 更多