I have a textarea control that is bound to a string variable (Angular2). That string variable is set from a Firebase database object (observable using AngularFire). I want to save the textarea value every time the user presses the "Enter" key.
However, when I save the textarea value to the database, the observable fires, updates the variable, and refreshes the textarea. The texarea loses focus. I could re-focus the textarea, but the cursor position would be lost.
How can I prevent the textarea from refreshing after the save? Or, how else can I achieve a seamless user experience?
I figured it out. In the observable callback function, I avoided updating the variable that is bound to the textarea control when the form model and database values matched.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.