Skip to content

Commit b4fe00f

Browse files
committed
docs: fix strict property initialization errors
Updates the code to be compatible with strict property initialization.
1 parent c7b4609 commit b4fe00f

File tree

39 files changed

+77
-85
lines changed

39 files changed

+77
-85
lines changed

src/components-examples/cdk/a11y/focus-monitor-focus-via/focus-monitor-focus-via-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class FocusMonitorFocusViaExample implements OnDestroy, AfterViewInit {
2424
private _cdr = inject(ChangeDetectorRef);
2525
private _ngZone = inject(NgZone);
2626

27-
@ViewChild('monitored') monitoredEl: ElementRef<HTMLElement>;
27+
@ViewChild('monitored') monitoredEl!: ElementRef<HTMLElement>;
2828

2929
origin = this.formatOrigin(null);
3030

src/components-examples/cdk/a11y/focus-monitor-overview/focus-monitor-overview-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export class FocusMonitorOverviewExample implements OnDestroy, AfterViewInit {
2121
private _cdr = inject(ChangeDetectorRef);
2222
private _ngZone = inject(NgZone);
2323

24-
@ViewChild('element') element: ElementRef<HTMLElement>;
25-
@ViewChild('subtree') subtree: ElementRef<HTMLElement>;
24+
@ViewChild('element') element!: ElementRef<HTMLElement>;
25+
@ViewChild('subtree') subtree!: ElementRef<HTMLElement>;
2626

2727
elementOrigin = this.formatOrigin(null);
2828
subtreeOrigin = this.formatOrigin(null);

src/components-examples/cdk/dialog/cdk-dialog-overview/cdk-dialog-overview-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class CdkDialogOverviewExample {
1919
dialog = inject(Dialog);
2020

2121
animal: string | undefined;
22-
name: string;
22+
name!: string;
2323

2424
openDialog(): void {
2525
const dialogRef = this.dialog.open<string>(CdkDialogOverviewExampleDialog, {

src/components-examples/cdk/drag-drop/cdk-drag-drop-root-element/cdk-drag-drop-root-element-example.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ export class CdkDragDropRootElementExample implements AfterViewInit, OnDestroy {
2525
private _injector = inject(Injector);
2626
private _viewContainerRef = inject(ViewContainerRef);
2727

28-
@ViewChild(TemplateRef) _dialogTemplate: TemplateRef<any>;
29-
private _overlayRef: OverlayRef;
30-
private _portal: TemplatePortal;
28+
@ViewChild(TemplateRef) _dialogTemplate!: TemplateRef<any>;
29+
private _overlayRef!: OverlayRef;
30+
private _portal!: TemplatePortal;
3131

3232
ngAfterViewInit() {
3333
this._portal = new TemplatePortal(this._dialogTemplate, this._viewContainerRef);

src/components-examples/cdk/drag-drop/cdk-drag-drop-table/cdk-drag-drop-table-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const ELEMENT_DATA: PeriodicElement[] = [
3434
imports: [CdkDropList, CdkDrag, MatTableModule, MatIconModule],
3535
})
3636
export class CdkDragDropTableExample {
37-
@ViewChild('table', {static: true}) table: MatTable<PeriodicElement>;
37+
@ViewChild('table', {static: true}) table!: MatTable<PeriodicElement>;
3838

3939
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol', 'quantity'];
4040
dataSource = ELEMENT_DATA;

src/components-examples/cdk/layout/breakpoint-observer-overview/breakpoint-observer-overview-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {takeUntil} from 'rxjs/operators';
1111
})
1212
export class BreakpointObserverOverviewExample implements OnDestroy {
1313
destroyed = new Subject<void>();
14-
currentScreenSize: string;
14+
currentScreenSize!: string;
1515

1616
// Create a map to display breakpoint names for demonstration purposes.
1717
displayNameMap = new Map([

src/components-examples/cdk/portal/cdk-portal-overview/cdk-portal-overview-example.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import {
2727
export class CdkPortalOverviewExample implements AfterViewInit {
2828
private _viewContainerRef = inject(ViewContainerRef);
2929

30-
@ViewChild('templatePortalContent') templatePortalContent: TemplateRef<unknown>;
31-
@ViewChild('domPortalContent') domPortalContent: ElementRef<HTMLElement>;
30+
@ViewChild('templatePortalContent') templatePortalContent!: TemplateRef<unknown>;
31+
@ViewChild('domPortalContent') domPortalContent!: ElementRef<HTMLElement>;
3232

33-
selectedPortal: Portal<any>;
34-
componentPortal: ComponentPortal<ComponentPortalExample>;
35-
templatePortal: TemplatePortal<any>;
36-
domPortal: DomPortal<any>;
33+
selectedPortal!: Portal<any>;
34+
componentPortal!: ComponentPortal<ComponentPortalExample>;
35+
templatePortal!: TemplatePortal<any>;
36+
domPortal!: DomPortal<any>;
3737

3838
ngAfterViewInit() {
3939
this.componentPortal = new ComponentPortal(ComponentPortalExample);

src/components-examples/cdk/text-field/text-field-autofill-directive/text-field-autofill-directive-example.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ import {MatFormFieldModule} from '@angular/material/form-field';
1212
imports: [MatFormFieldModule, MatInputModule, TextFieldModule, MatButtonModule],
1313
})
1414
export class TextFieldAutofillDirectiveExample {
15-
firstNameAutofilled: boolean;
16-
lastNameAutofilled: boolean;
15+
firstNameAutofilled = false;
16+
lastNameAutofilled = false;
1717
}

src/components-examples/cdk/text-field/text-field-autofill-monitor/text-field-autofill-monitor-example.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import {MatFormFieldModule} from '@angular/material/form-field';
1414
export class TextFieldAutofillMonitorExample implements AfterViewInit, OnDestroy {
1515
private _autofill = inject(AutofillMonitor);
1616

17-
@ViewChild('first', {read: ElementRef}) firstName: ElementRef<HTMLElement>;
18-
@ViewChild('last', {read: ElementRef}) lastName: ElementRef<HTMLElement>;
19-
firstNameAutofilled: boolean;
20-
lastNameAutofilled: boolean;
17+
@ViewChild('first', {read: ElementRef}) firstName!: ElementRef<HTMLElement>;
18+
@ViewChild('last', {read: ElementRef}) lastName!: ElementRef<HTMLElement>;
19+
firstNameAutofilled = false;
20+
lastNameAutofilled = false;
2121

2222
ngAfterViewInit() {
2323
this._autofill

src/components-examples/cdk/text-field/text-field-autosize-textarea/text-field-autosize-textarea-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {MatFormFieldModule} from '@angular/material/form-field';
1414
export class TextFieldAutosizeTextareaExample {
1515
private _injector = inject(Injector);
1616

17-
@ViewChild('autosize') autosize: CdkTextareaAutosize;
17+
@ViewChild('autosize') autosize!: CdkTextareaAutosize;
1818

1919
triggerResize() {
2020
// Wait for content to render, then trigger textarea resize.

0 commit comments

Comments
 (0)