DataTable - onLazyLoad causes expression changed exception in Angular 4.x
I'm submitting a ... (check one with "x")
[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
Current behavior Using datatable with virtual scrolling and lazy loading and subsequently setting data inside of onLazyLoad which is then used in templates causes to the Angular 4.x. expression changed exception. This is a problem for dev builds and karma unit testing. Hint: currently circumventing by embedding the onLazyLoad code in a setTimeout call.
Expected behavior onLazyLoad should be called outside of change detection context i.e. it should be possible to set data in onLazyLoad without resorting to timeouts etc.
What is the motivation / use case for changing the behavior? DataTabe with lazy loading is very useful, but broken tests prevent it from being tested properly.
** Repro ** Set the data actually being used in dataTable in onLazyLoad e.g. data = [1,2,3,4] and total = data.length and use it in the template e.g. . In dev build it should cause the exception and it should work alright when embedded in setTimeout.
Please tell us about your environment: Windows 10, npm, ng console.
-
Angular version: 4.2.5
-
PrimeNG version: 4.1.0-rc.3
-
Browser: Chrome
-
Language: TypeScript 2.3
-
Node (for AoT issues):
node --version= v6.10.3
Same issue here. Throws "Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'NaNpx'. Current value: '0px'".
Duplicate of #3041 and it is fixed with RC3.
@fxmfr your case actually looks more like the issue #3041 which I don't have anymore with latest release.
@Mrtcndkn this is definitely not a duplicate of #3041.
Sorry for misunderstanding could you please create a plunkr because I am unable to replicate at the moment.
@Mrtcndkn I'm not sure it would be possible as the expression changed exception is only thrown for dev built angular apps?