Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/cdk/a11y/a11y.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ be used to create accessible experience for components like
[modal dialogs](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/), where focus must be
constrained.

This directive is declared in `A11yModule`.
Import `CdkTrapFocus` in your component to use this directive.

#### Example

Expand Down Expand Up @@ -139,10 +139,11 @@ for more information on aria-live regions.
```ts
@Component({...})
export class MyComponent {
private liveAnnouncer = inject(LiveAnnouncer);

constructor(liveAnnouncer: LiveAnnouncer) {
liveAnnouncer.announce("Hey Google");
}
announceMessage() {
this.liveAnnouncer.announce("Hey Google");
}
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/cdk/a11y/focus-trap/focus-trap.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ be used to create accessible experience for components like
[modal dialogs](https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/), where focus must be
constrained.

This directive is declared in `A11yModule`.
Import `CdkTrapFocus` in your component to use this directive.

#### Example

Expand Down
10 changes: 5 additions & 5 deletions src/cdk/a11y/live-announcer/live-announcer.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ Announce the given message via aria-live region. The politeness argument determi
`aria-live` attribute on the announcer element, defaulting to 'polite'.

#### Examples
The LiveAnnouncer is injected into a component:
The `LiveAnnouncer` is injected into a component:
```ts
@Component({
selector: 'my-component'
providers: [LiveAnnouncer]
selector: 'my-component',
})
export class MyComponent {
private liveAnnouncer = inject(LiveAnnouncer);

constructor(liveAnnouncer: LiveAnnouncer) {
liveAnnouncer.announce("Hey Google");
announceMessage() {
this.liveAnnouncer.announce("Hey Google");
}
}
```
6 changes: 3 additions & 3 deletions src/cdk/clipboard/clipboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ directly to place it on the clipboard.
import {Clipboard} from '@angular/cdk/clipboard';

class HeroProfile {
constructor(private clipboard: Clipboard) {}
private clipboard = inject(Clipboard);

copyHeroName() {
this.clipboard.copy('Alphonso');
Expand All @@ -39,9 +39,9 @@ the text that was buffered. Please note, if you call `beginCopy`, you must clean
import {Clipboard} from '@angular/cdk/clipboard';

class HeroProfile {
lifetimeAchievements: string;
private clipboard = inject(Clipboard);

constructor(private clipboard: Clipboard) {}
lifetimeAchievements: string;

copyAchievements() {
const pending = this.clipboard.beginCopy(this.lifetimeAchievements);
Expand Down
12 changes: 6 additions & 6 deletions src/cdk/layout/breakpoints-observer.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### BreakpointsModule
### BreakpointObserver

When including the CDK's `LayoutModule`, components can inject `BreakpointsObserver` to request
the matching state of a CSS Media Query.
`BreakpointObserver` is an injectable service that lets you evaluate media queries to determine
the current screen size and react to changes when the viewport size crosses a breakpoint.

A set of breakpoints is provided based on the Material Design
[breakpoint system](https://material.io/guidelines/layout/responsive-ui.html#responsive-ui-breakpoints).
Expand All @@ -10,10 +10,10 @@ A set of breakpoints is provided based on the Material Design
```ts
@Component({ ... })
export class MyWidget {
isHandset: Observable<BreakpointState>;
private breakpointObserver = inject(BreakpointObserver);

constructor(bm: BreakpointObserver) {
bm.observe(Handset).subscribe((state: BreakpointState) => {
constructor() {
this.breakpointObserver.observe(Handset).subscribe((state: BreakpointState) => {
if (state.matches) {
this.makeEverythingFitOnSmallScreen();
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/cdk/layout/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ The `matchMedia` method can be used to get a native
```ts
@Component({...})
class MyComponent {
constructor(mediaMatcher: MediaMatcher) {
const mediaQueryList = mediaMatcher.matchMedia('(min-width: 1px)');
}
private mediaMatcher = inject(MediaMatcher);
private mediaQueryList = this.mediaMatcher.matchMedia('(min-width: 1px)');
}
```
18 changes: 10 additions & 8 deletions src/cdk/layout/media-matcher.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
### MediaMatcher
When including the CDK's `LayoutModule`, components can inject `MediaMatcher` to access the
matchMedia method, if available on the platform.

`MediaMatcher` is an injectable service that provides access to the `matchMedia` method, if
available on the platform.

#### Example
```ts
@Component({ ... })
export class MyWidget {
constructor(mm: MediaMatcher) {
mm.matchMedia('(orientation: landscape)').matches ?
@Component({ ... })
export class MyWidget {
private mediaMatcher = inject(MediaMatcher);

checkOrientation() {
this.mediaMatcher.matchMedia('(orientation: landscape)').matches ?
this.setLandscapeMode() :
this.setPortraitMode();
}
}
}
```