Skip to content

Commit 7e4f241

Browse files
authored
Merge pull request #99 from RiskChallenger/master
docs: clarify DialogRef typings in readme
2 parents d9228cb + 2d4e69a commit 7e4f241

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ interface Data {
4343
template: `
4444
<h1>{{title}}</h1>
4545
<button (click)="ref.close(true)">Close</button>
46-
`
46+
`,
4747
standalone: true,
4848
changeDetection: ChangeDetectionStrategy.OnPush
4949
})
5050
export class HelloWorldComponent {
51-
ref: DialogRef<Data> = inject(DialogRef);
51+
ref: DialogRef<Data, boolean> = inject(DialogRef);
5252

5353
get title() {
5454
if (!this.ref.data) return 'Hello world';
@@ -61,9 +61,9 @@ Inside the component, you'll have access to a `DialogRef` provider. You can call
6161

6262
> 💡 Tip
6363
>
64-
> If you define the types for your DialogRef provider, the `afterClosed$` and `close(params)` will be typed automatically.
64+
> A publicly accessible property of type `DialogRef<Input, Output>` on your component will be used to infer the input and output types of your component.
6565
66-
Now we can use the `DialogService` to open open the modal and display the component:
66+
Now we can use the `DialogService` to open the modal and display the component:
6767

6868
```ts
6969
import { DialogService } from '@ngneat/dialog';
@@ -131,7 +131,7 @@ import { DialogService, DialogRef } from '@ngneat/dialog';
131131
template: `
132132
<h1>{{ ref.data.title }}</h1>
133133
<button (click)="ref.close()">Close</button>
134-
`
134+
`,
135135
standalone: true,
136136
changeDetection: ChangeDetectionStrategy.OnPush
137137
})
@@ -201,12 +201,12 @@ import { DialogService } from '@ngneat/dialog';
201201
})
202202
export class AppComponent implements OnInit {
203203
private dialog = inject(DialogService);
204-
private id = '...';
204+
private title = 'Dialog title';
205205

206-
ngOnInit() {
206+
open() {
207207
const dialogRef = this.dialog.open(HelloWorldComponent, {
208208
data: {
209-
id: this.id,
209+
title: this.title,
210210
},
211211
});
212212
}

0 commit comments

Comments
 (0)