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
4 changes: 2 additions & 2 deletions src/cdk/a11y/a11y.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Intended to be used with components that correspond to a `role="menu"` or `role=
#### Basic usage

Any component that uses a `ListKeyManager` will generally do three things:
* Create a `@ViewChildren` query for the options being managed.
* Create a `viewChildren` query for the options being managed.
* Initialize the `ListKeyManager`, passing in the options.
* Forward keyboard events from the managed component to the `ListKeyManager`.

Expand Down Expand Up @@ -63,7 +63,7 @@ components that implement a `role="tree"` pattern.
#### Basic usage

Any component that uses a `TreeKeyManager` should do three things:
* Create a `@ViewChildren` query for the tree items being managed.
* Create a `viewChildren` query for the tree items being managed.
* Initialize the `TreeKeyManager`, passing in the options.
* Forward keyboard events from the managed component to the `TreeKeyManager` via `onKeydown`.

Expand Down
2 changes: 1 addition & 1 deletion src/google-maps/google-map/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GoogleMap

The `GoogleMap` component wraps the [`google.maps.Map` class](https://developers.google.com/maps/documentation/javascript/reference/map) from the Google Maps JavaScript API. You can configure the map via the component's inputs. The `options` input accepts a full [`google.maps.MapOptions` object](https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions), and the component additionally offers convenience inputs for setting the `center` and `zoom` of the map without needing an entire `google.maps.MapOptions` object. The `height` and `width` inputs accept a string to set the size of the Google map. [Events](https://developers.google.com/maps/documentation/javascript/reference/map#Map.bounds_changed) can be bound using the outputs of the `GoogleMap` component, although events have the same name as native mouse events (e.g. `mouseenter`) have been prefixed with "map" as to not collide with the native mouse events. Other members on the `google.maps.Map` object are available on the `GoogleMap` component and can be accessed using the [`ViewChild` decorator](https://angular.dev/api/core/ViewChild) or via [`viewChild`](https://angular.dev/api/core/viewChild).
The `GoogleMap` component wraps the [`google.maps.Map` class](https://developers.google.com/maps/documentation/javascript/reference/map) from the Google Maps JavaScript API. You can configure the map via the component's inputs. The `options` input accepts a full [`google.maps.MapOptions` object](https://developers.google.com/maps/documentation/javascript/reference/map#MapOptions), and the component additionally offers convenience inputs for setting the `center` and `zoom` of the map without needing an entire `google.maps.MapOptions` object. The `height` and `width` inputs accept a string to set the size of the Google map. [Events](https://developers.google.com/maps/documentation/javascript/reference/map#Map.bounds_changed) can be bound using the outputs of the `GoogleMap` component, although events have the same name as native mouse events (e.g. `mouseenter`) have been prefixed with "map" as to not collide with the native mouse events. Other members on the `google.maps.Map` object are available on the `GoogleMap` component and can be accessed using [`viewChild`](https://angular.dev/api/core/viewChild).

## Example

Expand Down
8 changes: 4 additions & 4 deletions src/google-maps/map-info-window/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

The `MapInfoWindow` component wraps the [`google.maps.InfoWindow` class](https://developers.google.com/maps/documentation/javascript/reference/info-window#InfoWindow) from the Google Maps JavaScript API. The `MapInfoWindow` has an `options` input as well as a convenience `position` input. Content for the `MapInfoWindow` is the inner HTML of the component, and will keep the structure and css styling of any content that is put there when it is displayed as an info window on the map.

To display the `MapInfoWindow`, it must be a child of a `GoogleMap` component, and it must have its `open` method called, so a reference to `MapInfoWindow` will need to be loaded using the [`ViewChild` decorator](https://angular.dev/api/core/ViewChild) or via [`viewChild`](https://angular.dev/api/core/viewChild). The `open` method accepts an `MapMarker` as an optional input, if you want to anchor the `MapInfoWindow` to a `MapMarker`.
To display the `MapInfoWindow`, it must be a child of a `GoogleMap` component, and it must have its `open` method called, so a reference to `MapInfoWindow` will need to be loaded using the [`viewChild`](https://angular.dev/api/core/viewChild) function. The `open` method accepts an `MapMarker` as an optional input, if you want to anchor the `MapInfoWindow` to a `MapMarker`.

## Example

```typescript
// google-maps-demo.component.ts
import {Component, ViewChild} from '@angular/core';
import {Component, viewChild} from '@angular/core';
import {GoogleMap, MapInfoWindow, MapMarker} from '@angular/google-maps';

@Component({
Expand All @@ -17,7 +17,7 @@ import {GoogleMap, MapInfoWindow, MapMarker} from '@angular/google-maps';
imports: [GoogleMap, MapInfoWindow, MapMarker],
})
export class GoogleMapDemo {
@ViewChild(MapInfoWindow) infoWindow: MapInfoWindow;
infoWindow = viewChild.required(MapInfoWindow);

center: google.maps.LatLngLiteral = {lat: 24, lng: 12};
markerPositions: google.maps.LatLngLiteral[] = [];
Expand All @@ -28,7 +28,7 @@ export class GoogleMapDemo {
}

openInfoWindow(marker: MapMarker) {
this.infoWindow.open(marker);
this.infoWindow().open(marker);
}
}
```
Expand Down
19 changes: 11 additions & 8 deletions src/material/core/ripple/ripple.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ the `matRippleTrigger` option that expects a reference to an `HTMLElement`.
Ripples can be shown programmatically by getting a reference to the `MatRipple` directive.

```ts
import {viewChild} from '@angular/core';

class MyComponent {

/** Reference to the directive instance of the ripple. */
@ViewChild(MatRipple) ripple: MatRipple;
ripple = viewChild.required(MatRipple);

/** Shows a centered and persistent ripple. */
launchRipple() {
const rippleRef = this.ripple.launch({
const rippleRef = this.ripple().launch({
persistent: true,
centered: true
});
Expand Down Expand Up @@ -89,11 +91,11 @@ const globalRippleConfig: RippleGlobalOptions = {
}
};

@NgModule({
bootstrapApplication(MyApp, {
providers: [
{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useValue: globalRippleConfig}
]
})
});
```

All available global options can be seen in the `RippleGlobalOptions` interface.
Expand Down Expand Up @@ -158,21 +160,22 @@ export class AppGlobalRippleOptions implements RippleGlobalOptions {
```

```ts
@NgModule({
bootstrapApplication(MyApp, {
providers: [
{provide: MAT_RIPPLE_GLOBAL_OPTIONS, useExisting: AppGlobalRippleOptions},
]
})
export class MyModule {...}
});
```

Now that the global ripple options are set to a service we can inject, the service can be
used update any global ripple option at runtime.

```ts
import {inject} from '@angular/core';

@Component(...)
export class MyComponent {
constructor(private _appRippleOptions: AppGlobalRippleOptions) {}
private _appRippleOptions = inject(AppGlobalRippleOptions);

disableRipples() {
this._appRippleOptions.disabled = true;
Expand Down
10 changes: 6 additions & 4 deletions src/material/datepicker/datepicker.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,16 @@ bootstrapApplication(MyApp, {
```

Because `DateAdapter` is a generic class, `MatDatepicker` and `MatDatepickerInput` also need to be
made generic. When working with these classes (for example as a `ViewChild`) you should include the
appropriate generic type that corresponds to the `DateAdapter` implementation you are using. For
example:
made generic. When working with these classes (for example as a `viewChild` query) you should
include the appropriate generic type that corresponds to the `DateAdapter` implementation you are
using. For example:

```ts
import {viewChild} from '@angular/core';

@Component({...})
export class MyComponent {
@ViewChild(MatDatepicker) datepicker: MatDatepicker<Date>;
datepicker = viewChild.required<MatDatepicker<Date>>(MatDatepicker);
}
```

Expand Down
6 changes: 4 additions & 2 deletions src/material/menu/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ The menu exposes an API to open/close programmatically. Please note that in this
`matMenuTriggerFor` directive is still necessary to attach the menu to a trigger element in the DOM.

```ts
import {viewChild} from '@angular/core';

class MyComponent {
@ViewChild(MatMenuTrigger) trigger: MatMenuTrigger;
trigger = viewChild.required(MatMenuTrigger);

someMethod() {
this.trigger.openMenu();
this.trigger().openMenu();
}
}
```
Expand Down
12 changes: 8 additions & 4 deletions src/material/sidenav/sidenav.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,15 @@ To react to scrolling inside the `<mat-sidenav-container>`, you can get a hold o
`CdkScrollable` instance through the `MatSidenavContainer`.

```ts
class YourComponent implements AfterViewInit {
@ViewChild(MatSidenavContainer) sidenavContainer: MatSidenavContainer;
import {viewChild} from '@angular/core';

ngAfterViewInit() {
this.sidenavContainer.scrollable.elementScrolled().subscribe(() => /* react to scrolling */);
class YourComponent {
sidenavContainer = viewChild.required(MatSidenavContainer);

constructor() {
afterNextRender(() => {
this.sidenavContainer().scrollable.elementScrolled().subscribe(() => /* react to scrolling */);
});
}
}
```
Expand Down