John Brunner John Brunner - 19 days ago 9
HTML Question

Textarea: Allow to begin with linebreak

I'm developing an Ionic/Cordova App. There is an

textarea
visible where user can input some data, which is transferred to the server.

Problem I face right now is that user can input line breaks, but just after they already inputted a character, but it is not possible to begin with an line break. The
ng-model
will cut out the beginning line breaks. How can I achieve my goal?

The
textarea
looks like that:

<textarea ng-model="card.text" id="text-message" rows="20"></textarea>


Thank you.

Answer

According to https://github.com/angular/angular.js/issues/2010 you can apply ng-trim="false" to your element to stop this behaviour like so:

<textarea ng-model="card.text" ng-trim="false" id="text-message" rows="20"></textarea>
Comments