admin管理员组文章数量:1023866
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;
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;
本文标签:
版权声明:本文标题:ionic framework - How to check if the passed reference is an instance of a particular ViewChild Reference in Angular - Stack Ove 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745565084a2156399.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论