Skip to content
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

Components created by VirtualScroll are outside of the Angular Zone #10451

Closed
frederikschubert opened this issue Feb 15, 2017 · 6 comments
Closed
Assignees
Milestone

Comments

@frederikschubert
Copy link

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

Components that are created by the VirtualScroll, are running outside the Angular zone.

Expected behavior:

The Components should be created in the Angular zone. Otherwise the change detection does not work properly.

Steps to reproduce:

http://plnkr.co/edit/cgtc3d?p=preview

Other information:

This should be wrapped with NgZone#run.

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

@jgw96
Copy link
Contributor

jgw96 commented Feb 15, 2017

Hello, thanks for using Ionic! We will look into this.

@jgw96 jgw96 added the v2 label Feb 15, 2017
@JustasKuizinas
Copy link

At the moment there are a lot of problems with virtual scroll, maybe anyone can suggest alternative?

@frederikschubert
Copy link
Author

frederikschubert commented Mar 2, 2017

Are there any plans to fix this or will a PR be accepted? This is a blocker for our apps and forces us to stay on RC.3.

@JustasKuizinas
Copy link

Virtual scroll buvs is also blocker for our app, hope they fix it in 2017 :)

@KillerCodeMonkey
Copy link
Contributor

as a workaround --> use the OnPush ChangeDetectionStrategy.

import { ChangeDetectorRef, ChangeDetectionStrategy, Component } from '@angular/core';
// ...

@Component({
  templateUrl: 'invoice.list.html',
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class MyPage {
  data: Data[];

  constructor(
    public dataService: DataService,
    public changeDetector: ChangeDetectorRef
  ) {
    dataService.get().then(res => {
      this.data = res;
      this.changeDetector.markForCheck();
    }, err => {
      console.log(err);
    });
  }
}

If you update the data/ items of the virtual scroll use

this.changeDetector.detectChanges();

Hacky, and i do not know if this will have sideeffects or if there are collisions if another detection runs.

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 3, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants