Angular contenteditable 更改事件未触发

Angular contenteditable change event not fired

我在 execCommand 上对我的控制器范围应用直接更改时遇到问题。

change 事件未在找到的 contenteditable 指令中触发 ,我必须模糊 div 才能应用更改。是 bug 还是有什么需要补充的?

这是我的 jsfiddle 用于测试。

=== 编辑 ===

大胆的 execCommand 正在 dom 但它不会直接更新控制器范围,除非事件被触发,例如场上的 keyup 或模糊。

change 事件不会在对 DOM 元素的值进行所有更改时触发。解决方案是使用 input 事件。

  element.on('input', function() {
      scope.$evalAsync(read);
  });

change

Unlike the input event, the change event is not necessarily fired for each change to an element's value.

--Mozilla Developer Network -- Events -- Change


input

The DOM input event is fired synchronously when the value of an <input> or <textarea> element is changed. Additionally, it fires on contenteditable editors when its contents are changed. In this case, the event target is the editing host element. If there are two or more elements which have contenteditable as true, "editing host" is the nearest ancestor element whose parent isn't editable.

--Mozilla Developer Network -- Events -- Input