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

Pagination doesn't update when created with *ngIf #4

Closed
StdVectorBool opened this issue Jan 24, 2017 · 1 comment
Closed

Pagination doesn't update when created with *ngIf #4

StdVectorBool opened this issue Jan 24, 2017 · 1 comment

Comments

@StdVectorBool
Copy link

We're using ngIf to hide the Pagination component if there's only one page of results and found the component isn't subscribed to DefaultTableStatePagination's events.

This line uses table.tableStateChange events to register listener for tableState.pagination.changed:
https://github.com/hoveytech/ng2-power-table/blob/565ffa9caa1d0e349cca1d2075a665fc2cc8b8d8/src/Pagination/Pagination.component.ts#L51

but those events are only fired on init or reference change:
https://github.com/hoveytech/ng2-power-table/blob/0c870a451b97530147bbad31acf898089c83bdc3/src/Table/Table.directive.ts#L62
https://github.com/hoveytech/ng2-power-table/blob/0c870a451b97530147bbad31acf898089c83bdc3/src/Table/Table.directive.ts#L70
https://github.com/hoveytech/ng2-power-table/blob/0c870a451b97530147bbad31acf898089c83bdc3/src/Table/Table.directive.ts#L85

So if Pagination is instantiated (or deleted and re-instantiated) after Table is already up and running then it never registers for the tableState.pagination events.

Binding to the component's 'hidden' attribute is a work-around but has other issues that make ngIf the preferred method for conditionally displaying a part of the DOM:
http://www.talkingdotnet.com/dont-use-hidden-attribute-angularjs-2/

@StdVectorBool StdVectorBool changed the title Pagination does update when created with *ngIf Pagination doesn't update when created with *ngIf Jan 24, 2017
@dahovey
Copy link
Member

dahovey commented Jan 31, 2017

Version 0.2.2 has been published to npm to fix this issue.

Thanks.

@dahovey dahovey closed this as completed Jan 31, 2017
ghost pushed a commit that referenced this issue Jan 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants