有点棘手的情况.对于下面的代码,我添加了(keydown.enter)=“false”来忽略textarea中的break line / enter按钮
这导致用户问题,并希望按Enter键的现有行为应自动触发“保存按钮”
任何想法如何在仍然聚焦在textArea但忽略断裂线时触发Save按钮?
<textarea #textArea style="overflow:hidden; height:auto; resize:none;" rows="1" class="form-control" [attr.placeholder]="placeholder" [attr.maxlength]="maxlength" [attr.autofocus]="autofocus" [name]="name" [attr.readonly]="readonly ? true : null" [attr.required]="required ? true : null" (input)="onUpdated($event)" [tabindex]="skipTab ? -1 : ''" (keydown.enter)="false" [(ngModel)]="value"> </textarea >
解决方法
您可以将“保存”按钮的相同功能绑定到texterea的keydown.enter,并调用$event.preventDefault以避免换行.
样品plunker.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。