Skip to content

[RC 3.0] If else doesn't hide components when the condition result changes #777

Closed
@sebawita

Description

@sebawita

When using If else in html, the components that shouldn't be visible don't seem to be removed. Instead each time the condition changes a new ng template gets generated. This creates multiple versions of the same templates over time.

Here is an example:

<ActionBar title="My App" class="action-bar">
</ActionBar>
<StackLayout class="page">
  <Placeholder *ngIf="size < 6; then small else big"> 
  </Placeholder>

  <ng-template #small>
    <Label text="Small"></Label>
  </ng-template>
  <ng-template #big>
    <Label text="Big"></Label>
  </ng-template>

  <Label [text]="size"></Label>
  
  <Button text="+" (tap)="add()" class="btn btn-primary"></Button>
  <Button text="-" (tap)="sub()" class="btn btn-primary"></Button>
</StackLayout>
export class ItemsComponent {
  size: number = 5;
  constructor() { }

  add() {  this.size++; }
  sub() {  this.size--; }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions