@@ -19,6 +19,7 @@ import {
1919 inject ,
2020} from '@angular/core' ;
2121import { Directionality } from '@angular/cdk/bidi' ;
22+ import { _IdGenerator } from '@angular/cdk/a11y' ;
2223import { ScrollDispatcher } from '@angular/cdk/scrolling' ;
2324import { CDK_DROP_LIST , CdkDrag } from './drag' ;
2425import { CdkDragDrop , CdkDragEnter , CdkDragExit , CdkDragSortEvent } from '../drag-events' ;
@@ -31,9 +32,6 @@ import {merge, Subject} from 'rxjs';
3132import { startWith , takeUntil } from 'rxjs/operators' ;
3233import { assertElementNode } from './assertions' ;
3334
34- /** Counter used to generate unique ids for drop zones. */
35- let _uniqueIdCounter = 0 ;
36-
3735/** Container that wraps a set of draggable items. */
3836@Directive ( {
3937 selector : '[cdkDropList], cdk-drop-list' ,
@@ -91,7 +89,7 @@ export class CdkDropList<T = any> implements OnDestroy {
9189 * Unique ID for the drop zone. Can be used as a reference
9290 * in the `connectedTo` of another `CdkDropList`.
9391 */
94- @Input ( ) id : string = ` cdk-drop-list-${ _uniqueIdCounter ++ } ` ;
92+ @Input ( ) id : string = inject ( _IdGenerator ) . getId ( ' cdk-drop-list-' ) ;
9593
9694 /** Locks the position of the draggable elements inside the container along the specified axis. */
9795 @Input ( 'cdkDropListLockAxis' ) lockAxis : DragAxis ;
0 commit comments