Skip to content

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

Closed

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--; }
}

Activity

  1. self-assigned this
    on May 2, 2017
  2. added a commit that references this issue on May 5, 2017
    a8582b2
  3. added this to the milestone on May 5, 2017
  4. added a commit that references this issue on May 8, 2017
    6dd8b18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions