角度和内容可编辑 [英] Angular and contenteditable
本文介绍了角度和内容可编辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在网上搜索过,但找不到在 Angular 6/7 上使用 contenteditable
事件的方法.Angualr 似乎有一个凌乱的解决方案,但该功能似乎并未延续到最新版本.
一个用例是在内容可编辑的 onChange
事件上,调用一个函数:
对此有什么想法吗?谢谢.
解决方案 您可以使用 input
事件,如下所示:
输入您的姓名
I've searched the web but can't find a way to work with contenteditable
events on Angular 6/7. Angualr seem to have a messy solution with it but said feature doesn't seem to be carried over to recent versions.
A use case would be is on a content editable onChange
event, call a function:
<div contententeditable="true" [change]="onNameChange(if.there.is.such.a.thing)">Type your name</div>
...
private name: string;
onNameChange(name) {
this.name = name;
}
Any ideas on this? Thanks.
解决方案 You can use the input
event, like so:
<div contenteditable (input)="onNameChange($event.target.innerHTML)">
Type your name
</div>
这篇关于角度和内容可编辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文