From 623af57252de6e29aa93ce6062de77e930e65944 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 3 Jan 2025 21:02:51 +0100 Subject: [PATCH] refactor(material/paginator): switch to inject function (#30253) Switches `mat-paginator` to use the `inject` function now that we've cleaned up the internal usages. (cherry picked from commit 53608997645cc51c4f526cd6563640e41d8b7561) --- src/material/paginator/paginator.ts | 19 ++++++++++++------- tools/public_api_guard/material/paginator.md | 5 ++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/material/paginator/paginator.ts b/src/material/paginator/paginator.ts index f774e7882f86..cfa0aeeca3eb 100644 --- a/src/material/paginator/paginator.ts +++ b/src/material/paginator/paginator.ts @@ -11,12 +11,10 @@ import { ChangeDetectorRef, Component, EventEmitter, - Inject, InjectionToken, Input, OnDestroy, OnInit, - Optional, Output, ViewEncapsulation, booleanAttribute, @@ -111,6 +109,9 @@ export const MAT_PAGINATOR_DEFAULT_OPTIONS = new InjectionToken = this._initializedStream; - constructor( - public _intl: MatPaginatorIntl, - private _changeDetectorRef: ChangeDetectorRef, - @Optional() @Inject(MAT_PAGINATOR_DEFAULT_OPTIONS) defaults?: MatPaginatorDefaultOptions, - ) { + /** Inserted by Angular inject() migration for backwards compatibility */ + constructor(...args: unknown[]); + + constructor() { + const _intl = this._intl; + const defaults = inject(MAT_PAGINATOR_DEFAULT_OPTIONS, { + optional: true, + }); + this._intlChanges = _intl.changes.subscribe(() => this._changeDetectorRef.markForCheck()); if (defaults) { diff --git a/tools/public_api_guard/material/paginator.md b/tools/public_api_guard/material/paginator.md index 26cc3875d2bb..078b87634a49 100644 --- a/tools/public_api_guard/material/paginator.md +++ b/tools/public_api_guard/material/paginator.md @@ -4,7 +4,6 @@ ```ts -import { ChangeDetectorRef } from '@angular/core'; import { EventEmitter } from '@angular/core'; import * as i0 from '@angular/core'; import * as i1 from '@angular/material/button'; @@ -34,7 +33,7 @@ export function MAT_PAGINATOR_INTL_PROVIDER_FACTORY(parentIntl: MatPaginatorIntl // @public export class MatPaginator implements OnInit, OnDestroy { - constructor(_intl: MatPaginatorIntl, _changeDetectorRef: ChangeDetectorRef, defaults?: MatPaginatorDefaultOptions); + constructor(...args: unknown[]); protected _buttonClicked(targetIndex: number, isDisabled: boolean): void; _changePageSize(pageSize: number): void; color: ThemePalette; @@ -85,7 +84,7 @@ export class MatPaginator implements OnInit, OnDestroy { // (undocumented) static ɵcmp: i0.ɵɵComponentDeclaration; // (undocumented) - static ɵfac: i0.ɵɵFactoryDeclaration; + static ɵfac: i0.ɵɵFactoryDeclaration; } // @public