Skip to content

Commit

Permalink
fix(module:pagination) fix pagination double binding (#146)
Browse files Browse the repository at this point in the history
close #107
  • Loading branch information
vthinkxie authored Aug 25, 2017
1 parent 49e3741 commit b442863
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/pagination/nz-pagination.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ describe('NzPaginationComponent', () => {
expect(debugElement.nativeElement.querySelectorAll('.ant-pagination-item').length).toBe(6);
expect(debugElement.nativeElement.querySelector('.ant-pagination-jump-next')).toBeDefined();
});
it('correct double binding', () => {
const fixture = TestBed.createComponent(TestPaginationBasic);
const testComponent = fixture.debugElement.componentInstance;
const debugElement = fixture.debugElement.query(By.directive(NzPaginationComponent));
testComponent._nzTotal = 50;
fixture.detectChanges();
debugElement.nativeElement.querySelector('.ant-pagination-item:nth-child(4)').click();
fixture.detectChanges();
expect(testComponent._nzPageIndex).toBe(3);
});

it('change each page to display the entry', () => {
const fixture = TestBed.createComponent(TestPaginationChanger);
Expand Down Expand Up @@ -113,7 +123,7 @@ describe('NzPaginationComponent', () => {
@Component({
selector: 'nz-test-pagination-basic',
template: `
<nz-pagination [nzPageIndex]="_nzPageIndex" [nzTotal]="_nzTotal"></nz-pagination>
<nz-pagination [(nzPageIndex)]="_nzPageIndex" [nzTotal]="_nzTotal"></nz-pagination>
`
})
class TestPaginationBasic {
Expand Down
1 change: 1 addition & 0 deletions src/components/pagination/nz-pagination.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ export class NzPaginationComponent {
this.nzPageIndex = index;
}
this.nzPageIndexClickChange.emit(this.nzPageIndex);
this.nzPageIndexChange.emit(this.nzPageIndex);
}

get _isLastIndex() {
Expand Down
1 change: 0 additions & 1 deletion src/components/table/nz-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export class NzTableComponent implements AfterViewInit {
};

pageChangeClick(value) {
this.nzPageIndex = value;
this.nzPageIndexChangeClick.emit(value);
}

Expand Down

0 comments on commit b442863

Please sign in to comment.