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 9481e5d
Showing 1 changed file with 8 additions and 8 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 false;
}

this.pageChanged.emit({
page: this._page,
itemsPerPage: this.itemsPerPage
Expand Down

0 comments on commit 9481e5d

Please sign in to comment.