Skip to content

Commit 638533c

Browse files
yogeshwaran-ccrisbeto
authored andcommitted
docs: convert remaining @NgModule provider examples to bootstrapApplication (#32840)
(cherry picked from commit 267b658)
1 parent 87aa6d9 commit 638533c

8 files changed

Lines changed: 37 additions & 47 deletions

File tree

src/cdk/overlay/overlay.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,9 @@ The `FullscreenOverlayContainer` is an alternative to `OverlayContainer` that su
9797
displaying of overlay elements in
9898
[fullscreen mode](https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen).
9999

100-
`FullscreenOverlayContainer` can be enabled by providing it in your `NgModule`:
100+
`FullscreenOverlayContainer` can be enabled by providing it in your app config:
101101
```ts
102-
@NgModule({
103-
providers: [{provide: OverlayContainer, useClass: FullscreenOverlayContainer}],
104-
// ...
105-
})
106-
export class MyModule { }
102+
bootstrapApplication(MyApp, {
103+
providers: [{provide: OverlayContainer, useClass: FullscreenOverlayContainer}]
104+
});
107105
```

src/material-experimental/README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ component by following these steps:
3030
...
3131
```
3232

33-
3. Import the `NgModule` for the component you want to use. For example, the checkbox:
33+
3. Import the component you want to use. For example, the checkbox:
3434
```ts
35-
import {MatCheckboxModule} from '@angular/material/checkbox';
35+
import {Component} from '@angular/core';
36+
import {MatCheckbox} from '@angular/material/checkbox';
3637

37-
@NgModule({
38-
declarations: [MyComponent],
39-
imports: [MatCheckboxModule],
38+
@Component({
39+
imports: [MatCheckbox],
40+
// ...
4041
})
41-
export class MyModule {}
42+
export class MyComponent {}
4243
```
4344

4445
4. Use the components just as you would the normal Angular Material components. For example,

src/material/chips/chips.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ By default, chips are displayed horizontally. To stack chips vertically, apply t
111111

112112
Use the `MAT_CHIPS_DEFAULT_OPTIONS` token to specify default options for the chips module.
113113

114-
```html
115-
@NgModule({
114+
```ts
115+
bootstrapApplication(MyApp, {
116116
providers: [
117117
{
118118
provide: MAT_CHIPS_DEFAULT_OPTIONS,
@@ -121,7 +121,7 @@ Use the `MAT_CHIPS_DEFAULT_OPTIONS` token to specify default options for the chi
121121
}
122122
}
123123
]
124-
})
124+
});
125125
```
126126

127127
### Interaction Patterns

src/material/form-field/form-field.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ Out of the box, if you do not specify an `appearance` for the `<mat-form-field>`
2727
appearance for your app.
2828

2929
```ts
30-
@NgModule({
30+
bootstrapApplication(MyApp, {
3131
providers: [
3232
{provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {appearance: 'outline'}}
3333
]
34-
})
34+
});
3535
```
3636

3737
<!-- example(form-field-appearance) -->
@@ -54,15 +54,15 @@ field control, or to `auto` to restore the default behavior.
5454
<!-- example(form-field-label) -->
5555

5656
The floating label behavior can be adjusted globally by providing a value for
57-
`MAT_FORM_FIELD_DEFAULT_OPTIONS` in your application's root module. Like the `floatLabel` input,
57+
`MAT_FORM_FIELD_DEFAULT_OPTIONS` in your app config. Like the `floatLabel` input,
5858
the option can be either set to `always` or `auto`.
5959

6060
```ts
61-
@NgModule({
61+
bootstrapApplication(MyApp, {
6262
providers: [
6363
{provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {floatLabel: 'always'}}
6464
]
65-
})
65+
});
6666
```
6767

6868
### Hint labels

src/material/input/input.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ applies to all inputs. For convenience, `ShowOnDirtyErrorStateMatcher` is availa
6565
globally cause input errors to show when the input is dirty and invalid.
6666

6767
```ts
68-
@NgModule({
68+
bootstrapApplication(MyApp, {
6969
providers: [
7070
{provide: ErrorStateMatcher, useClass: ShowOnDirtyErrorStateMatcher}
7171
]
72-
})
72+
});
7373
```
7474

7575
### Auto-resizing `<textarea>` elements

src/material/select/select.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ applies to all inputs. For convenience, `ShowOnDirtyErrorStateMatcher` is availa
139139
globally cause input errors to show when the input is dirty and invalid.
140140

141141
```ts
142-
@NgModule({
142+
bootstrapApplication(MyApp, {
143143
providers: [
144144
{provide: ErrorStateMatcher, useClass: ShowOnDirtyErrorStateMatcher}
145145
]
146-
})
146+
});
147147
```
148148

149149
### Keyboard interaction

src/material/stepper/stepper.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,17 @@ However, it can be overridden the same way as mentioned above.
153153

154154
In order to use the custom step states, you must add the `displayDefaultIndicatorType` option to
155155
the global default stepper options which can be specified by providing a value for
156-
`STEPPER_GLOBAL_OPTIONS` in your application's root module.
156+
`STEPPER_GLOBAL_OPTIONS` in your app config.
157157

158158
```ts
159-
@NgModule({
159+
bootstrapApplication(MyApp, {
160160
providers: [
161161
{
162162
provide: STEPPER_GLOBAL_OPTIONS,
163163
useValue: { displayDefaultIndicatorType: false }
164164
}
165165
]
166-
})
166+
});
167167
```
168168

169169
<!-- example(stepper-states) -->
@@ -177,14 +177,14 @@ errors via the `showError` option in the `STEPPER_GLOBAL_OPTIONS` injection toke
177177
will not affect steppers marked as `linear`.
178178

179179
```ts
180-
@NgModule({
180+
bootstrapApplication(MyApp, {
181181
providers: [
182182
{
183183
provide: STEPPER_GLOBAL_OPTIONS,
184184
useValue: { showError: true }
185185
}
186186
]
187-
})
187+
});
188188
```
189189

190190
<!-- example(stepper-errors) -->
@@ -213,16 +213,14 @@ viewport.
213213

214214
### Localizing labels
215215
Labels used by the stepper are provided through `MatStepperIntl`. Localization of these messages
216-
can be done by providing a subclass with translated values in your application root module.
216+
can be done by providing a subclass with translated values in your app config.
217217

218218
```ts
219-
@NgModule({
220-
imports: [MatStepperModule],
219+
bootstrapApplication(MyApp, {
221220
providers: [
222221
{provide: MatStepperIntl, useClass: MyIntl},
223-
],
224-
})
225-
export class MyApp {}
222+
]
223+
});
226224
```
227225

228226
<!-- example(stepper-intl) -->

src/youtube-player/README.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ File any bugs against the [angular/components repo](https://github.com/angular/c
88
To install, run `ng add @angular/youtube-player`.
99

1010
## Usage
11-
Import the component either by adding the `YouTubePlayerModule` to your app or by importing
12-
`YouTubePlayer` into a standalone component. Then add the `<youtube-player videoId="<your ID>"`
11+
Import `YouTubePlayer` into your component. Then add the `<youtube-player videoId="<your ID>"`
1312
to your template.
1413

1514
## Example
@@ -43,19 +42,16 @@ If you don't want it to be loaded, you can either control it on a per-component
4342
Or at a global level using the `YOUTUBE_PLAYER_CONFIG` injection token:
4443

4544
```typescript
46-
import {NgModule} from '@angular/core';
4745
import {YouTubePlayer, YOUTUBE_PLAYER_CONFIG} from '@angular/youtube-player';
4846

49-
@NgModule({
50-
imports: [YouTubePlayer],
47+
bootstrapApplication(YourApp, {
5148
providers: [{
5249
provide: YOUTUBE_PLAYER_CONFIG,
5350
useValue: {
5451
loadApi: false
5552
}
5653
}]
57-
})
58-
export class YourApp {}
54+
});
5955
```
6056

6157
## Loading behavior
@@ -78,19 +74,16 @@ initialization, you can either pass in the `disablePlaceholder` input:
7874
Or set it at a global level using the `YOUTUBE_PLAYER_CONFIG` injection token:
7975

8076
```typescript
81-
import {NgModule} from '@angular/core';
8277
import {YouTubePlayer, YOUTUBE_PLAYER_CONFIG} from '@angular/youtube-player';
8378

84-
@NgModule({
85-
imports: [YouTubePlayer],
79+
bootstrapApplication(YourApp, {
8680
providers: [{
8781
provide: YOUTUBE_PLAYER_CONFIG,
8882
useValue: {
8983
disablePlaceholder: true
9084
}
9185
}]
92-
})
93-
export class YourApp {}
86+
});
9487
```
9588

9689
### Placeholder image quality

0 commit comments

Comments
 (0)