You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We saw that the pageChanged event is fired three times at the initialization of the pagination component. We expected to have only one.
After investigating a bit, it's linked to the use of a TypeScript setter for the page property with a custom event. Because Angular2 fires events asynchronously (see this issue: angular/angular#6311), setting values to the page property fires event after the component initialization
We saw an inited property but it doesn't seem to be useful in this context...
We wonder if it's a normal behavior or a bug.
Here are some proposals to only have one events fired at the component startup:
Hi,
I've discovered this bug today as well. However, I believe that 'pageChanged' event shouldn't be fired even on component init but only if page is really changed. I've sent pull request for this bug.
valorkin
changed the title
ng2-bootstrap pagination pageChanged triggered multiple times
chore(pagination): pageChanged triggered multiple times
Feb 6, 2016
Hi all,
I open this issue following a question on StackOverflow. See http://stackoverflow.com/questions/35081261/ng2-bootstrap-pagination-pagechanged-triggered-multiple-times/.
We saw that the
pageChanged
event is fired three times at the initialization of thepagination
component. We expected to have only one.After investigating a bit, it's linked to the use of a TypeScript setter for the
page
property with a custom event. Because Angular2 fires events asynchronously (see this issue: angular/angular#6311), setting values to thepage
property fires event after the component initializationWe saw an
inited
property but it doesn't seem to be useful in this context...We wonder if it's a normal behavior or a bug.
Here are some proposals to only have one events fired at the component startup:
(file
node_modules/ng2-bootstrap/components/pagination/pagination.ts
):Update the
set page
block to trigger events only when theinited
property istrue
:Update the
ngOnInit
method not to set theinited
property to true at its end:Set the
inited
property to true at the end of the first call of thewriteValue
:Thanks very much for your feedback!
Thierry
The text was updated successfully, but these errors were encountered: