AngularJS application:
The ng-model directives bind the input fields to the controller properties.In my application the inputs with spaces are ignored, for example : " A"
,the resulting output is "A"
.
Is there a way to include those white spaces as well ?
Fiddled here
Thanks
AngularJS application:
The ng-model directives bind the input fields to the controller properties.In my application the inputs with spaces are ignored, for example : " A"
,the resulting output is "A"
.
Is there a way to include those white spaces as well ?
Fiddled here
Thanks
Share Improve this question asked Apr 17, 2015 at 9:30 TharifTharif 14k10 gold badges57 silver badges78 bronze badges2 Answers
Reset to default 7You can add the ng-trim="false"
attribute to stop Angular from trimming the extra whitespace in input fields.
Besides that, you also have the additional problem that the whitespace isn't rendered in HTML.
You can fix this for example by using
Full Name: <pre>{{Location + " " + Item}}</pre>
Demo fiddle
Or alternatively by using css:
white-space: pre;
Demo fiddle
Use ng-trim="false"
directive:
<input type="text" ng-model="Location" ng-trim="false">
DEMO: http://jsfiddle/pa6sdudd/4/