6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { Component , Inject , TemplateRef , ViewChild , ViewEncapsulation } from '@angular/core' ;
10
- import { DIALOG_DATA , Dialog , DialogConfig , DialogRef , DialogModule } from '@angular/cdk/dialog' ;
9
+ import { DIALOG_DATA , Dialog , DialogConfig , DialogModule , DialogRef } from '@angular/cdk/dialog' ;
10
+ import {
11
+ ChangeDetectionStrategy ,
12
+ ChangeDetectorRef ,
13
+ Component ,
14
+ Inject ,
15
+ TemplateRef ,
16
+ ViewChild ,
17
+ ViewEncapsulation ,
18
+ inject ,
19
+ } from '@angular/core' ;
11
20
import { FormsModule } from '@angular/forms' ;
12
21
13
22
const defaultDialogConfig = new DialogConfig ( ) ;
@@ -19,6 +28,7 @@ const defaultDialogConfig = new DialogConfig();
19
28
encapsulation : ViewEncapsulation . None ,
20
29
standalone : true ,
21
30
imports : [ DialogModule , FormsModule ] ,
31
+ changeDetection : ChangeDetectionStrategy . OnPush ,
22
32
} )
23
33
export class DialogDemo {
24
34
dialogRef : DialogRef < string > | null ;
@@ -43,6 +53,8 @@ export class DialogDemo {
43
53
44
54
@ViewChild ( TemplateRef ) template : TemplateRef < any > ;
45
55
56
+ readonly cdr = inject ( ChangeDetectorRef ) ;
57
+
46
58
constructor ( public dialog : Dialog ) { }
47
59
48
60
openJazz ( ) {
@@ -51,12 +63,19 @@ export class DialogDemo {
51
63
this . dialogRef . closed . subscribe ( result => {
52
64
this . result = result ! ;
53
65
this . dialogRef = null ;
66
+ this . cdr . markForCheck ( ) ;
54
67
} ) ;
55
68
}
56
69
57
70
openTemplate ( ) {
58
71
this . numTemplateOpens ++ ;
59
- this . dialog . open ( this . template , this . config ) ;
72
+ this . dialogRef = this . dialog . open ( this . template , this . config ) ;
73
+
74
+ this . dialogRef . closed . subscribe ( result => {
75
+ this . result = result ! ;
76
+ this . dialogRef = null ;
77
+ this . cdr . markForCheck ( ) ;
78
+ } ) ;
60
79
}
61
80
}
62
81
@@ -92,6 +111,7 @@ export class DialogDemo {
92
111
}
93
112
` ,
94
113
standalone : true ,
114
+ changeDetection : ChangeDetectionStrategy . OnPush ,
95
115
} )
96
116
export class JazzDialog {
97
117
private _dimensionToggle = false ;
0 commit comments