I want to know if it's possible to select a textarea's content when it gets modified. In jQuery, I'd do the following:
$("texarea").on("change", function (e) {
$(this).select(); // the content gets selected for copy/cut operations
});
I know it's a bad practice to directly manipulate DOM elements from within an angular controller, so if you know how I can do this cleanly, I'd be happy to learn how!
I think you can do the following, attach an event handler to your textfield element using onblur
and onfocus
attributes. Write two functions for each as follows:
onfocus
get the initial content of the textfield
onblur
get the final content and compare to the initial content if there is a difference the run the select function
If you want it to be in real time your could also use onkeyup
and onkeydown