ionic framework - How to check if the passed reference is an instance of a particular ViewChild Reference in Angular - Stack Ove

I have a viewchild ref in my .ts file like,@ViewChild('someDialog') someDialog: ElementRef;a

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

Change 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条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信