问题
Friends,
I waant to update my record using popover and i have to used angularjs directive.my popover is open but data not populated in textbox and update button click not working below my cod which i used
SCRIPT :
var mymodal = angular.module('mymodal', []);
mymodal.controller('MainCtrl', function ($scope) {
$scope.days = [{ 'ID': 1, 'name': 'Sunday' },
{ 'ID': 2, 'name': 'Monday' },
{ 'ID': 3, 'name': 'Tuesday' },
{ 'ID': 4, 'name': 'Wednesday' },
{ 'ID': 5, 'name': 'Thursday' },
{ 'ID': 6, 'name': 'Friday' },
{ 'ID': 7, 'name': 'Saturday' }];
$scope.editSave = function () {
alert('Update!');
}
$scope.ProphenDelete = function () {
alert('Delete!');
}
});
mymodal.directive('bsPopover', function () {
return function (scope, element, attrs) {
var popOverContent = "<modal title='Add/Update/Delete'>"
+ '<form role="form">'
+ '<div class="form-group">'
+ '<input type="text" class="form-control" id="txt" ng-bind="modedit.editProfaneWord" ng-model="editProfaneWord"/>'
+ '<input type="hidden" name="someData" ng-model="ID" /> '
+ '</div>'
+ '<button class="btn btn-primary" ng-click="editSave()">Save</button> '
+ '<button class="btn btn-primary" ng-click="ProphenDelete()">Delete</button>'
+ '</form></modal>';
element.find("a[rel=popover]").popover({
placement: 'bottom',
html: 'true',
content: popOverContent,
title: attrs.popoverPlacement
});
};
});
HTML :
<div ng-app="mymodal">
<div ng-controller="MainCtrl" class="container">
<table>
<tr ng-repeat="cust in days" bs-popover>
<td>
<a rel="popover" ng-bind="cust.name"></a>
</td>
</tr>
</table>
</div>
来源:https://stackoverflow.com/questions/32263313/how-to-open-popover-for-update-my-record-in-angularjs