【发布时间】:2018-08-08 21:17:28
【问题描述】:
如何获取新输入的字符(不是 ngModel 的全新值)然后对其应用逻辑,然后为 ngModel 返回一个新值?
示例: 假设当用户在输入中键入时,我们希望获取他键入的新字符,然后将其更改为某些内容并将其附加到之前的值ng模型。试过 keypress 和 onModelChange 但似乎没有用
<ion-textarea #chat_input
(ngModelChange)="modelChanged($event)"
placeholder="Text Input"
[ngModel]="editorMsg"
(keyup.enter)="sendMsg()"
(ionFocus)="onFocus()">
</ion-textarea>
而我的方法是这样的:
modelChanged(e){
// e is the new value of editorMsg and not the new typed character, if I get the new character I can do
this.editorMsg+=e;
}
但我只能从modelChange 获得新输入的值,我怎样才能只获得新输入的字符?
【问题讨论】:
标签: javascript angular input