如何通过单击angularjs项目中的卡片图像来打开引导模态框



我正在为我的angularjs项目编写代码,其中UI的一部分有卡片。所以我想通过单击卡片图像打开一个模态框。 目前,我已经在图像下方创建了一个按钮,单击该按钮将打开模态框。 这工作正常。但是,我想单击卡片图像,而不是单击按钮,它应该打开模态框。我正在下面附加当前代码。这方面的任何帮助都将是非常可观的。谢谢

<div class="col-md-4 clearfix d-none d-md-block">
<div class="card mb-2">
<div class="avatar-wrapper">
<img class="profile-pic" src="/assets/images/abc.jpg" />
<div class="upload-button">
</div>               
</div>
<div class="card-body">            
<h4> <button type="button" class="card-title text-center font-weight-bold" data-toggle="modal" data-target="#basicExampleModal3">
abc receipe </button>  </h4>
<h3 class="description">This is short description in the card body.hio dvdjvd sscg sdgscsc sgssd sdjg c edsc sdcfsc dfkopseuccs sc</h3 >     
<div class= "modal fade" id="basicExampleModal3" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel3"
aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel3">Receipe-abc by dfgr</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body ">
<img class="profile-pic" src="/assets/images/abc.jpg" />
<p> Modal Box Description.                 
sdc
dfvdv
sscg sdgscsc dfvfd
</p>
</div>                
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>                  
</div>             
</div>
</div>
</div>
</div>
</div>
</div>

data-toggle="modal" data-target="#basicExampleModal3"添加到图像元素,如下所示

<img class="profile-pic" src="/assets/images/abc.jpg"  data-toggle="modal" data-target="#basicExampleModal3"/>

检查代码段,现在单击图像以打开模态

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="col-md-4 clearfix  d-md-block">
<div class="card mb-2">
<div class="avatar-wrapper">
<img class="profile-pic" src="/assets/images/abc.jpg" data-toggle="modal" data-target="#basicExampleModal3" />
<div class="upload-button">
</div>
</div>
<div class="card-body">
<h4> <button type="button" class="card-title text-center font-weight-bold">
abc receipe</button> (click on button wont work, click on image to check) </h4>
<h3 class="description">This is short description in the card body.hio dvdjvd sscg sdgscsc sgssd sdjg c edsc sdcfsc dfkopseuccs sc</h3>
<div class="modal fade" id="basicExampleModal3" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel3" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel3">Receipe-abc by dfgr</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body ">
<img class="profile-pic" src="/assets/images/abc.jpg" />
<p> Modal Box Description.
sdc
dfvdv
sscg sdgscsc dfvfd
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

相关内容

  • 没有找到相关文章

最新更新