66 * found in the LICENSE file at https://angular.dev/license
77 */
88
9- import { AfterViewInit , Directive , ElementRef , NgZone , OnDestroy } from '@angular/core' ;
9+ import { AfterViewInit , Directive , ElementRef , inject , NgZone , OnDestroy } from '@angular/core' ;
10+ import { _IdGenerator } from '@angular/cdk/a11y' ;
1011import { fromEvent , merge , Subject } from 'rxjs' ;
1112import { filter , map , mapTo , pairwise , startWith , take , takeUntil } from 'rxjs/operators' ;
1213
@@ -19,14 +20,13 @@ import {HeaderRowEventDispatcher} from './event-dispatcher';
1920const HOVER_OR_ACTIVE_CLASS = 'cdk-column-resize-hover-or-active' ;
2021const WITH_RESIZED_COLUMN_CLASS = 'cdk-column-resize-with-resized-column' ;
2122
22- let nextId = 0 ;
23-
2423/**
2524 * Base class for ColumnResize directives which attach to mat-table elements to
2625 * provide common events and services for column resizing.
2726 */
2827@Directive ( )
2928export abstract class ColumnResize implements AfterViewInit , OnDestroy {
29+ private _idGenerator = inject ( _IdGenerator ) ;
3030 protected readonly destroyed = new Subject < void > ( ) ;
3131
3232 /* Publicly accessible interface for triggering and being notified of resizes. */
@@ -40,7 +40,7 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
4040 protected abstract readonly notifier : ColumnResizeNotifierSource ;
4141
4242 /** Unique ID for this table instance. */
43- protected readonly selectorId = ` ${ ++ nextId } ` ;
43+ protected readonly selectorId = this . _idGenerator . getId ( 'cdk-column-resize-' ) ;
4444
4545 /** The id attribute of the table, if specified. */
4646 id ?: string ;
@@ -60,7 +60,7 @@ export abstract class ColumnResize implements AfterViewInit, OnDestroy {
6060
6161 /** Gets the unique CSS class name for this table instance. */
6262 getUniqueCssClass ( ) {
63- return `cdk-column-resize- ${ this . selectorId } ` ;
63+ return this . selectorId ;
6464 }
6565
6666 /** Called when a column in the table is resized. Applies a css class to the table element. */
0 commit comments