@@ -29,9 +29,11 @@ in which they are contained. When closing, an optional result value can be provi
2929value is forwarded as the result of the ` afterClosed ` Observable.
3030
3131``` ts
32+ import {inject } from ' @angular/core' ;
33+
3234@Component ({/* ... */ })
3335export class YourDialog {
34- constructor ( public dialogRef : MatDialogRef < YourDialog >) { }
36+ dialogRef = inject ( MatDialogRef );
3537
3638 closeDialog() {
3739 this .dialogRef .close (' Pizza!' );
@@ -41,14 +43,14 @@ export class YourDialog {
4143
4244### Specifying global configuration defaults
4345Default dialog options can be specified by providing an instance of ` MatDialogConfig ` for
44- MAT_DIALOG_DEFAULT_OPTIONS in your application's root module .
46+ ` MAT_DIALOG_DEFAULT_OPTIONS ` in your app config .
4547
4648``` ts
47- @ NgModule ( {
49+ bootstrapApplication ( MyApp , {
4850 providers: [
4951 {provide: MAT_DIALOG_DEFAULT_OPTIONS , useValue: {hasBackdrop: false }}
5052 ]
51- })
53+ });
5254```
5355
5456### Sharing data with the Dialog component.
@@ -64,15 +66,15 @@ let dialogRef = dialog.open(YourDialog, {
6466To access the data in your dialog component, you have to use the MAT_DIALOG_DATA injection token:
6567
6668``` ts
67- import {Component , Inject } from ' @angular/core' ;
68- import {MAT_DIALOG_DATA } from ' .. /dialog' ;
69+ import {Component , inject } from ' @angular/core' ;
70+ import {MAT_DIALOG_DATA } from ' @angular/material /dialog' ;
6971
7072@Component ({
7173 selector: ' your-dialog' ,
7274 template: ' passed in {{ data.name }}' ,
7375})
7476export class YourDialog {
75- constructor (@ Inject ( MAT_DIALOG_DATA ) public data : {name: string }) { }
77+ data = inject < {name: string }>( MAT_DIALOG_DATA );
7678}
7779```
7880
0 commit comments