I have a viewchild ref in my .ts file like,
@ViewChild('someDialog') someDialog: ElementRef;
and in the .html file, I'm passing the reference back to a function like,
<abc-dialog #someDialog (close)="onDialogClose(someDialog)"></abc-dialog>
In my .ts file I want to check whether the passed reference to the onDialogClose() function is equal to someDialog view child ref.
Any help is highly appreciated, thank you.
I have a viewchild ref in my .ts file like,
@ViewChild('someDialog') someDialog: ElementRef;
and in the .html file, I'm passing the reference back to a function like,
<abc-dialog #someDialog (close)="onDialogClose(someDialog)"></abc-dialog>
In my .ts file I want to check whether the passed reference to the onDialogClose() function is equal to someDialog view child ref.
Any help is highly appreciated, thank you.
Share Improve this question edited Nov 19, 2024 at 11:32 Naren Murali 61.1k5 gold badges44 silver badges81 bronze badges asked Nov 19, 2024 at 11:12 LutherLuther 2803 silver badges11 bronze badges1 Answer
Reset to default 0Change your ViewChild
to look for the component.
The read
property gets the DI token you provide, here it is the component itself, so it will have the component reference.
@ViewChild('someDialog', { read: AbcDialogComponent }) someDialog: AbcDialogComponent;
or
The ViewChild
gets the DI token you provide, here it is the component itself, so it will have the component reference.
@ViewChild(AbcDialogComponent) someDialog: AbcDialogComponent;
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745565085a4633344.html
评论列表(0条)