Skip to content

Comments

docs(cdk): use inject() and remove unnecessary module references#32830

Open
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/cdk-modernize-inject-pattern
Open

docs(cdk): use inject() and remove unnecessary module references#32830
yogeshwaran-c wants to merge 1 commit intoangular:mainfrom
yogeshwaran-c:docs/cdk-modernize-inject-pattern

Conversation

@yogeshwaran-c
Copy link

What kind of change does this PR introduce?

Documentation improvement

What is the current behavior?

Several CDK documentation files use constructor-based dependency injection and reference legacy module imports:

  • a11y.md and focus-trap.md say CdkTrapFocus is "declared in A11yModule", but the directive can be imported directly
  • live-announcer.md lists LiveAnnouncer in component providers despite it being providedIn: 'root'
  • clipboard.md uses constructor injection for the Clipboard service
  • media-matcher.md and breakpoints-observer.md say to include LayoutModule, but MediaMatcher and BreakpointObserver are both providedIn: 'root'
  • All code examples use constructor injection instead of inject()

Part of #32709

What is the new behavior?

  • Replace "declared in A11yModule" with "Import CdkTrapFocus in your component"
  • Remove unnecessary providers: [LiveAnnouncer] and module import guidance
  • Update all code examples to use the inject() function
  • Fix the BreakpointsModule heading typo (should be BreakpointObserver)

Files changed

  • src/cdk/a11y/a11y.md - FocusTrap import guidance, LiveAnnouncer inject()
  • src/cdk/a11y/focus-trap/focus-trap.md - CdkTrapFocus import guidance
  • src/cdk/a11y/live-announcer/live-announcer.md - Remove unnecessary providers, inject()
  • src/cdk/clipboard/clipboard.md - Clipboard inject()
  • src/cdk/layout/breakpoints-observer.md - Fix heading, remove LayoutModule ref, inject()
  • src/cdk/layout/layout.md - MediaMatcher inject()
  • src/cdk/layout/media-matcher.md - Remove LayoutModule ref, inject()

Update CDK documentation to use the inject() function instead of
constructor injection, and remove misleading module import requirements
for services that are providedIn: 'root' (LiveAnnouncer, Clipboard,
MediaMatcher, BreakpointObserver). Also replace A11yModule references
with direct directive import guidance for CdkTrapFocus.
@angular-robot angular-robot bot added the area: docs Related to the documentation label Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant