S
S
Sergei Iamskoi2019-10-09 21:43:48
Angular
Sergei Iamskoi, 2019-10-09 21:43:48

How to turn off whitespace removal in Angular?

Good evening!
There is this code:

<div class="col-xs-6 ta-r">
    <h4>License:</h4> <p>Standard</p>
</div>

Angular collects it in:
<div class="col-xs-6 ta-r"><h4>License:</h4><p>Standard</p></div>

Thus, removing spaces and hyphens, as a result, I get a continuous spelling of License:Standard on the site.
If you insert nbsp; then when viewed via mobile, the result is very bad:

License:
Standard

Is there a way to turn off white space removal for this div block? I googled this command, but it didn't help:

"angularCompilerOptions": {
"preserveWhitespaces": false
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Anton Shvets, 2019-10-09
@Xuxicheta

Default is false, unless overridden in compiler options

So you have to put
"preserveWhitespaces": true

E
eRKa, 2019-10-10
@kttotto

The positioning of elements on the page should not depend on spaces and enters in the layout. Do customization with css. You, apparently, made it <h> и <p>inlan, which, judging by the context, is incorrect. Make them как <label> и как <span>accordingly, add the necessary css rules for size and weight, add margin-left. And then you don't have to look for crutches to remove spaces in the markup.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question