sachinchoolur / angular-trix

A rich WYSIWYG text editor directive for angularjs.
http://sachinchoolur.github.io/angular-trix/
MIT License
328 stars 62 forks source link

How do I get the contents of the editor? #7

Closed hcientist closed 8 years ago

hcientist commented 8 years ago

I want to make it so that if the user presses the enter key without shift, it will not add a newline, but will instead call a submit kind of function on my controller. I have previously been using textangular, but they don't have events or really anything to make this easy for me, and there i was encountering a race condition with reading the content. to test angular-trix, i made a small fork of the plunkr, see: http://plnkr.co/edit/2qC9DZEI8eOxNW74pS7J?p=preview (the plunkr is such that it will log $scope.trix after 5 seconds) so to test: i have the console open on the side and refresh the plunkr. immediately start typing real words. while watching for the console. you will see it log at 5 seconds, and in my tests, this had only the beginning contents of the model. How would i get the current typed text?

hcientist commented 8 years ago

INTERNETS! I repent. the friggin default plunkr uses ng-model-options="{ updateOn: 'blur' }" GUESS WHAT THAT DOES!? (it means it won't update the friggin ngmodel all the time)

i removed it et voilà http://plnkr.co/edit/Dx79CqqlaKEA1907jIH8?p=preview