Why white space is ignored in an AngularJS application

AngularJS app:

The ng-model directives associate input fields with controller properties. In my application, inputs with spaces are ignored, for example:, the " A"resulting output "A".

Is there any way to include these spaces?

enter image description here

Twisted here

thank

+4
source share
2 answers

You can add an attribute ng-trim="false"to stop Angular from trimming extra spaces in input fields .


In addition, you also have the additional problem that the space is not displayed in HTML .

You can fix this, for example using

Full Name: <pre>{{Location + " " + Item}}</pre>

Demo script

, , css:

white-space: pre;

-

+3

ng-trim="false" :

<input type="text" ng-model="Location" ng-trim="false">

DEMO: http://jsfiddle.net/pa6sdudd/4/

+5

All Articles