Skip to content

Commit

Permalink
fix(pagination): multiple triggering of pageChanged event, fix #76, fix
Browse files Browse the repository at this point in the history
#138, closes #146
  • Loading branch information
krzysztofsaja authored and valorkin committed Feb 6, 2016
1 parent fff99c2 commit 91c4ec4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions components/pagination/pagination.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import {
Component,
OnInit, Input, Output,
ElementRef, EventEmitter,
Self, Renderer
} from 'angular2/core';
import { NgFor, NgIf, NgClass, ControlValueAccessor, NgModel } from 'angular2/common';
import { IAttribute } from '../common';
import {Component, OnInit, Input, Output, ElementRef, EventEmitter, Self, Renderer} from 'angular2/core';
import {NgFor, NgIf, ControlValueAccessor, NgModel} from 'angular2/common';
import {IAttribute} from '../common';

// todo: extract base functionality classes
// todo: expose an option to change default configuration
Expand Down Expand Up @@ -135,8 +130,13 @@ export class Pagination implements ControlValueAccessor, OnInit, IPaginationConf
}

public set page(value) {
const _previous = this._page;
this._page = (value > this.totalPages) ? this.totalPages : (value || 1);

if (_previous === this._page || typeof _previous === 'undefined') {
return;
}

this.pageChanged.emit({
page: this._page,
itemsPerPage: this.itemsPerPage
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.3",
"description": "angular2 bootstrap components",
"scripts": {
"compile": "./node_modules/typescript/bin/tsc",
"compile": "./node_modules/.bin/tsc",
"prepublish": "./node_modules/.bin/tsc && ./make.js",
"publish:gh-pages": "./gh-pages-publish.js",
"postpublish": "npm run build:prod && npm run publish:gh-pages",
Expand Down

0 comments on commit 91c4ec4

Please sign in to comment.