数据目标-角度 [英] data-target - Angular
本文介绍了数据目标-角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在直接使用HTML显示对话框
I am displaying a dialog
by using HTML directly
<!-- Dialog -->
<div class="modal fade" id="exampleModalCenter" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="exampleModalLongTitle">Something went wrong</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<h5 class="modal-title" id="exampleModalLongTitle">Maximum 10 messages selected</h5>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Ok</button>
</div>
</div>
</div>
</div>
<button data-toggle="modal" data-target="#exampleModalCenter">RunIt</button>
但是我想先做些事情,所以我想通过JavaScript使用(点击)执行
data-toggle ="modal" data-target =#exampleModalCenter"
代码>
but I would like to do something previously so I would like to execute data-toggle="modal" data-target="#exampleModalCenter"
by javascript using (click)
所以基本上这是步骤:
1- (click)="test()"
2-通过 test()
要获取包含它的 DIV
,我已经尝试过:
to get the DIV
that contains it, I have tried:
test(){
var dialog= <HTMLDivElement>document.getElementById(exampleModalCenter);
}
但是我找不到 exampleModalCenter
推荐答案
您应该使用 attr.data-target
<button data-toggle="collapse"
[attr.data-target]="'#exampleModalCenter">RunIt
</button>
这篇关于数据目标-角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文