如何通过单击 angularjs 项目中的卡片图像打开 bootstrap 模态框
How to open bootstrap modalbox by clicking on the card image in angularjs project
我正在为我的 angularjs 项目编写代码,其中 UI 的一部分有卡片。所以我想通过点击卡片图片来打开一个模态框。
目前我在图像下方创建了一个按钮,单击该按钮将打开模态框。
这工作正常。但是我不想点击按钮,而是想点击卡片图像,它应该打开模态 box.I 我在下面附上当前代码。对此的任何帮助将不胜感激。谢谢
<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">×</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">×</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>
我正在为我的 angularjs 项目编写代码,其中 UI 的一部分有卡片。所以我想通过点击卡片图片来打开一个模态框。 目前我在图像下方创建了一个按钮,单击该按钮将打开模态框。 这工作正常。但是我不想点击按钮,而是想点击卡片图像,它应该打开模态 box.I 我在下面附上当前代码。对此的任何帮助将不胜感激。谢谢
<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">×</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">×</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>