@@ -137,8 +137,7 @@ export class MatPaginator implements OnInit, OnDestroy {
137137 return this . _pageIndex ;
138138 }
139139 set pageIndex ( value : number ) {
140- this . _pageIndex = Math . max ( value || 0 , 0 ) ;
141- this . _changeDetectorRef . markForCheck ( ) ;
140+ this . _navigate ( value ) ;
142141 }
143142 private _pageIndex = 0 ;
144143
@@ -306,11 +305,8 @@ export class MatPaginator implements OnInit, OnDestroy {
306305 // Current page needs to be updated to reflect the new page size. Navigate to the page
307306 // containing the previous page's first item.
308307 const startIndex = this . pageIndex * this . pageSize ;
309- const previousPageIndex = this . pageIndex ;
310-
311- this . pageIndex = Math . floor ( startIndex / pageSize ) || 0 ;
312308 this . pageSize = pageSize ;
313- this . _emitPageEvent ( previousPageIndex ) ;
309+ this . pageIndex = Math . floor ( startIndex / pageSize ) || 0 ;
314310 }
315311
316312 /** Checks whether the buttons for going forwards should be disabled. */
@@ -361,11 +357,11 @@ export class MatPaginator implements OnInit, OnDestroy {
361357
362358 /** Navigates to a specific page index. */
363359 private _navigate ( index : number ) {
364- const previousIndex = this . pageIndex ;
365-
366- if ( index !== previousIndex ) {
367- this . pageIndex = index ;
368- this . _emitPageEvent ( previousIndex ) ;
360+ if ( index !== this . pageIndex ) {
361+ const previousPageIndex = this . _pageIndex ;
362+ this . _pageIndex = Math . max ( index || 0 , 0 ) ;
363+ this . _changeDetectorRef . markForCheck ( ) ;
364+ this . _emitPageEvent ( previousPageIndex ) ;
369365 }
370366 }
371367
0 commit comments