I have a table in Angular that gets list of names. I want to be able to delete a name when the user click on the button in front of the name. However, before that, I want to show a modal and ask the user to confirm that.
<table class="table table-condensed table-striped">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr data-ng-repeat="c in vm.entity | filter:vm.filter track by c.Id">
<td>
<span>{{c.Name}}</span>
</td>
<td>
<button class="glyphicon glyphicon-trash" type="button" data-toggle="modal" data-target=".bs-example-modal-sm"></button>
</td>
</tr>
</tbody>
</table>
I am using Bootstap modal and here is what I have.
<div class="modal fade bs-example-modal-sm">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true"></span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Are you sure?</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this Item?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
<button type="button" data-ng-click="vm.remove(c)" data-dismiss="modal" class="btn btn-primary">Yes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
The problem is since the buttons in the modal are not in the loop I can't pass in the correct object into the vm.remove method to delete the item.
Does anyone know how to deal with this issue?
Ok Guys,
Thanks for all your help.
I have managed to fix it by moving the modal right next to the button so the modal is repeated as well as the button as #Dabbiemiller suggested and then I assign a ID for each modal that matches the id of each element, and I assign the data-target= "modal{{c.id}}" and it works :)
Also I have changed to becase the fade class was causing an issue as well.
<button class="glyphicon glyphicon-trash" ng-show="vm.isAdmin == 'True'" type="button" data-toggle="modal" data-target="#modal{{c.id}}"></button>
<div class="modal" id="modal{{c.id}}">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true"></span><span class="sr-only">Close</span></button>
<h4 class="modal-title">Are you sure?</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this Item?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
<button type="button" data-ng-click="vm.remove(c)" data-dismiss="modal" class="btn btn-primary">Yes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
Related
i want to display accordion under selected Book appointment Button in ng-repeat,But here it is displaying under first button..Please help! I Attached screen shot also..enter image description here
<tbody ng-repeat="schedule in scheduleListByDate | orderBy:'scheduledDate':false">
<tr>
<td>{{$index+1}}</td>
<td>{{changeDateformate(schedule.scheduledDate);}}</td>
<td>{{schedule.doctor.firstName}}{{schedule.doctor.lastName}}</td>
<td>{{schedule.fromTime | date:'HH:mm:ss'}}</td>
<td>{{schedule.toTime | date:'HH:mm:ss'}}</td>
<td>{{arrayToString(schedule.availableDays)}}</td>
<td>
<button class="btn label-info" data-toggle="collapse" data-target="#demo" ng-click="findScheduledHours(schedule);">Book
Appointment</button>
<div id="demo" class="collapse">
<form class="col-sm-12">
<div ng-repeat="scheduledHour in hoursList">
<div class="col-sm-3">
<button type="button" class="buttonAppointment" ng-click="selectScheduleSub(scheduledHourDto,scheduledHourDto.appointmentStartedDate,appointment.appointmentEnddate,scheduledHour);">{{scheduledHour}}</button>
</div>
</div>
</form>
</div>
</td>
</tr>
</tbody>
Try giving each one a unique id and corresponding data-target:
<button class="btn label-info" data-toggle="collapse" data-target="#demo_{{$index}}" ng-click="findScheduledHours(schedule);">Book Appointment</button>
<div id="demo_{{$index}}" class="collapse">
<form class="col-sm-12">
<div ng-repeat="scheduledHour in hoursList">
<div class="col-sm-3">
<button type="button" class="buttonAppointment" ng-click="selectScheduleSub(scheduledHourDto,scheduledHourDto.appointmentStartedDate,appointment.appointmentEnddate,scheduledHour);">{{scheduledHour}}</button>
</div>
</div>
</form>
</div>
I have to remove the image from the list in the conformation model click on the YES button but after 2nd time model is not open.In the element section after 2nd time click "
<span class="glyphicon glyphicon-remove-sign" data-toggle="modal" data-target="#openImage"></span>
<div id="openImage" class="modal in">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Are you sure???</h4>
</div>
<div class="modal-body">
<p>Are you sure you want to delete this product?</p>
<div class="row">
<div class="col-12-xs text-center">
<button class="btn btn-primary btn-md" ng-click="removeSelectedProductKey($event, productObject.keyId)"> Yes</button>
<button class="btn btn-default btn-md" data-dismiss="close">No</button>
</div>
</div>
</div>
</div>
</div>
</div>
display :none" is apply tell me sir how to resolve this problem?
Try to open your modal by function using:
<span class="glyphicon glyphicon-remove-sign" ng-click="openImg()"></span>
And inside your controller write below function:
function openImg(){
angular.element('#openImage').modal();
}
I need to show the bootstrap model popup which is in different page when click the anchor tag from angular controller the pop up shoul show.
I have anchor tag in one.aspx
<a id="fspstart" href="../Student/FspStartNotification.aspx" data-toggle-type="modal" data-target="#modalFSP"></a>
I have model popup in yes.ascx
<div id="modalFSP" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Congratulations!</h4>
</div>
<div class="modal-body">
<p><strong>Final Study Plan is available</strong></p>
<p>Cllick here to start your Final Study Plan.</p>
</div>
<div class="modal-footer">
<table>
<tr>
<td>
<asp:Button ID="btnStartFsp" class="btn btn-primary" runat="server" Text="Start Final Study Plan" Style="font-size: medium; text-align: center"
OnClick="btnStartFsp_click" />
<asp:Button ID="btnCancel" class="btn btn-default" runat="server" Text="Close" Style="font-size: medium; text-align: center"
CssClass="cancel" OnClick="btnCancel_click" />
</td>
</tr>
<tr>
<td>
<asp:CheckBox ID="chkboxMessage" runat="server" AutoPostBack="true" />
<asp:Label ID="lblchkbox" runat="server" Text="Do not show this again." Style="font-size: smaller"></asp:Label>
</td>
</tr>
</table>
<%--<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>--%>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
Click event triggered from one.controller
$('#fspstart').click();
but,Pop is not showing can you please help me out this where am wrong
Thanks
in my Form i have Buttons who only be shown then edit is true. Now i set edit from another Button and get a problem.
The View get editable, thats great. But the Buttons don´t showing. Whats wrong?
This is a bit of the code from my view.
<div ng-controller="MenuController" ng-init="edit=false" style="background:whitesmoke; border:1px solid lightgray; border-radius:5px; margin-top:0px; margin-bottom:5px; height:405px;">
<button prevent-default ng-click="" class="btn btn-deufol btn-sm pull-right" style="width:150px;margin:2px;"><span class="glyphicon glyphicon-print"></span> Lieferschein drucken</button>
<button prevent-default ng-click="" class="btn btn-deufol btn-sm pull-right" style="width:150px;margin:2px;"><span class="glyphicon glyphicon-print"></span> Auftrag drucken</button>
<button prevent-default ng-click="edit=true" ng-show="!edit" name="BtnWork" id="BtnWork" class="btn btn-deufol btn-sm pull-right" style="width:150px;margin:2px;"><span class="glyphicon glyphicon-pencil"></span> Bearbeiten</button>
<button prevent-default ng-click="resetData()" ng-show="edit" ng-model="BtnReset" id="BtnReset" e-form="textBtnForm" class="btn btn-danger btn-sm pull-right" style="width:150px;margin:2px;"><span class="glyphicon glyphicon-remove-circle"></span> Abbruch</button>
<button prevent-default ng-click="saveData()" ng-show="edit" id="BtnUpdate" class="btn btn-success btn-sm pull-right" style="width:150px;margin:2px;"><span class="glyphicon glyphicon-ok-circle"></span> Speichern</button>
<ul class="nav nav-tabs">
<li class="active">
<a data-target="#tab-one" data-toggle="tab"><i class="glyphicon glyphicon-list-alt"></i> Auftrag</a>
</li>
<li>
<a data-target="#tab-two" data-toggle="tab"><i class="glyphicon glyphicon-book"></i> Dokumente</a>
</li>
</ul>
<div class="tab-content css-form">
<div id="tab-one" class="tab-pane active">
<form name="InputForm" novalidate role="form" class="simple-form">
<div ng-view class="table-responsive table-singleview" style="position:relative;background:whitesmoke;margin-top:0px;margin-bottom:0px;">
<table border="0" style="width:100%; height:100%;">
<tbody ng-controller="ContractsSingleViewController">
<tr>
<td style="width:8%;" align="left">Standort</td>
<td style="width:25.3333%">
<div ng-controller="LocationsListController">
<span class="nullable">
<%--required--%>
<select placeholder="Standort" data-ng-model="myLocations" ng-disabled="!edit" ng-options="Plants._locationName for Plants in myLocationsList" style="width:281px;height:23px;background:whitesmoke;" class="ng-valid ng-dirty">
<option value="">{{myViewData.locationName}}</option>
</select>
</span>
<%--<span class="label label-danger" data-ng-show="myViewData.locationName.$error.required">Required!</span>--%>
</div>
</td>
.............
</table>
</tbody>
</div>
</form>
</div>
<%--Table one--%>
In my angular code i set edit = true like this (snippet):
$scope.edit = false;
Why this works for my table, but no for my buttons?
I cannot get tabs to work on the inside of my modal no matter what I do. If it matters the modal is within a ng-repeat with angularJS and the modal id is being called dynamically
<!--======== Trigger ========-->
<a data-toggle="modal" href='#{{faIcon.iconSelect}}'>Trigger Modal</a>
<!--======== modal ========-->
<div class="modal fade" id="{{faIcon.iconSelect}}">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"><i class="fa fa-fw">{{faIcon.theIcon}}</i>{{faIcon.name}}</h4>
</div>
<div class="modal-body">
<h1><i class="fa fa-fw">{{faIcon.theIcon}}</i></h1>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist" id="myTab">
<li class="active">1</li>
<li>2</li>
<li>3</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="1">1</div>
<div class="tab-pane" id="2">2</div>
<div class="tab-pane" id="3">3</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
<input ng-copy="copied=true" ng-init="copied=false; value='copy me'" ng-model="value">opied: {{copied}}
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--======== modal ========-->
Am i missing an init code or something
according to my tests it seems that you don't have any problems with the code so the problem is probably on another line of your code.
The easiest but most common things that make this kind of thing happen is that you probably forgat to close some tag..