4

I have a html template which should simply translate a state:

<ng-container [ngSwitch]="currentStatus">
  <ng-container *ngSwitchCase="'DRAFT'" i18n="@@DraftStatus">
    Draft
  </ng-container>
  <ng-container *ngSwitchCase=    ...
  <ng-container *ngSwitchDefault>
    {{currentStatus}}
  </ng-container>
</ng-container>
. End

But somehow as much as I try the content is always displayed as e.g. Draft . End. i.e. one additional space is added at the end of the container. I would like to display it like Draft. End.

Trying to use in the compontent the setting preserveWhitespaces: false, doesn't help neither.

Any hints how to get rid of this extra space?

1
  • Maybe that you have an additionnal space after Draft or End. Try inlining the tag: <ng-container *ngSwitchDefault> {{currentStatus}}</ng-container> and see if you still have the trailing space Commented Sep 4, 2019 at 13:58

2 Answers 2

5

You have necessarily a white space that you do not see. To be sure you can wrap your words in <span> like :

...
<ng-container *ngSwitchCase="'DRAFT'" i18n="@@DraftStatus">
   <span>Draft</span>
</ng-container>
...
<span>. End</span>

And be sure that you do not have space between your tags

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, that's the best approach to fix this issue on a long run. I don't want to rely on any special formatting within HTML - cuz my editor might mess it up. Thx.
1

You might not like this formatting (or perhaps you have auto-format on save set up, which would have to be disabled somehow), but this should solve the problem:

<ng-container [ngSwitch]="currentStatus">
  <ng-container *ngSwitchCase="'DRAFT'" i18n="@@DraftStatus">
    Draft</ng-container>
  <ng-container *ngSwitchCase=    ...
  <ng-container *ngSwitchDefault>
    {{currentStatus}}
  </ng-container>
</ng-container>. End

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.