Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sebawita opened this issue May 2, 2017 · 0 comments
Closed
Assignees
Labels
Milestone

Comments

@sebawita
Copy link
Contributor

sebawita commented May 2, 2017

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--; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants