Is there any syntax for conditional interpolation of a pattern?

I have an angular template (2.4.9) with the following element:

<div *ngIf="a || b || c || d || e">Remaining</div>

Now I am faced with the need to change this still static text “Remaining” based on another condition:

<div *ngIf="a || b || c || d || e || Z != 'draft'">Initial</div>
<div *ngIf="a || b || c || d || e || Z == 'draft'">Remaining</div>

*ngIf already loaded, and I would like not to duplicate it, as it was in the above example, just to add this additional condition.

I would also like to avoid this:

<div *ngIf="a || b || c || d || e">
    <div *ngIf="Z != 'draft'">Initial</div>
    <div *ngIf="Z == 'draft'">Remaining</div>
</div>

... because it changes the structure of the page and therefore the style rules.

So, instead of introducing a new element into the div with its own *ngIf, which would add style rules, I was looking for something like conditional interpolation syntax so that I could write

<div *ngIf="many || conditions">{{ status === "DRAFT" ? 'Initial' : 'Remaining' }}</div>

, {{ 1 + 1 }}, , , , , .

, , -, , , , , .

+4
2

Angular4 else

<template #other>
  <div>Remaining</div>
</template>

<div *ngIf="a || b || c || d || e || Z != 'draft'; else other">Initial</div>

Angular2, getter method getter *ngIf="..."

+6

. , RemyaJ.

0

Source: https://habr.com/ru/post/1673626/


All Articles