admin管理员组

文章数量:1336396

I would show message depending on a 2 values

<div *ngIf="nolimit; else limited">
   <p class="isGroup">No limit message</p>
</div>
<div *ngIf="noDelegation; else limited">
   <p class="isGroup">No delegation</p>
</div>
<ng-template #limited>
  Content here
</ng-template>

I would that either isGroup message shows or no delegation if they are both false I should show content #limited

My actual problem is that I get no limit message and #limited content together when nolimit is true:

no limit

Content Here

But When I delete no delegation code, evetything is working.

I would show message depending on a 2 values

<div *ngIf="nolimit; else limited">
   <p class="isGroup">No limit message</p>
</div>
<div *ngIf="noDelegation; else limited">
   <p class="isGroup">No delegation</p>
</div>
<ng-template #limited>
  Content here
</ng-template>

I would that either isGroup message shows or no delegation if they are both false I should show content #limited

My actual problem is that I get no limit message and #limited content together when nolimit is true:

no limit

Content Here

But When I delete no delegation code, evetything is working.

Share Improve this question asked Sep 17, 2018 at 17:23 infodevinfodev 5,24522 gold badges81 silver badges152 bronze badges 1
  • 1 Why not creating three divs and then using *ngIf="!nolimit && !noDelegation" on the last one that will show Content here text – SiddAjmera Commented Sep 17, 2018 at 17:27
Add a ment  | 

2 Answers 2

Reset to default 5

It would be better to use three divs and then use *ngIf="!nolimit && !noDelegation" on the last one that will show Content here text

<div>
  <div *ngIf="nolimit">
    <p class="isGroup">No limit message</p>
  </div>
  <div *ngIf="noDelegation">
    <p class="isGroup">No delegation</p>
  </div>
</div>

<div *ngIf="!nolimit && !noDelegation">
  Content here
</div>

I think it has to do with the microsintax:

<div [ngIf]="nolimit" [ngIfElse]="limited">
  <p class="isGroup">No limit message</p>
</div>

<div [ngIf]="noDelegation" [ngIfElse]="limited">
  <p class="isGroup">No delegation</p>
</div>

<ng-template #limited>
 Content here
</ng-template>

本文标签: javascriptngIf else if in AngularStack Overflow