var app = angular.module('plunker', ['ui.bootstrap']);
app.controller('MainCtrl', function($scope, $uibModal) {
$scope.names=[
{id:1,reg_date:'2001-01-01', approval:true, status:1, orderer:true, creator:true, production_type:'one', date:'20017-01-01'},
{id:1,reg_date:'2002-02-02', approval:false, status:1, orderer:false, creator:false, production_type:'two', date:'20017-02-02'}]
var templateModal = "<div class='modal-header'>" +
"<button type='button' class='close' ng-click='cancel()'>×</button>" +
"</div>" +
"<div class='modal-body'>" +
"<span>ID</span> <input type='text' readonly='readonly' name='id' value='{{names.id}}' ng-model='editable.id'><br/>" +
"<span>Approval</span> <input type='text' name='approval' value='{{names.approval}}' ng-model='editable.approval'><br/>" +
"<span>Status</span> <input type='text' name='status' value='{{names.status}}' ng-model='editable.status'><br/>" +
"<span>Orderer</span> <input type='text' name='orderer' value='{{names.orderer}}' ng-model='editable.orderer'><br/>" +
"<span>Creator</span> <input type='text' name='creator' value='{{names.creator}}' ng-model='editable.creator'><br/>" +
"<span>Production Type</span> <input type='text' name='production_type' value='{{names.production_type}}' ng-model='editable.production_type'><br/>" +
"<span>First Posting Date</span> <input type='text' name='date' value='{{names.date}}' ng-model='editable.date'><br/>" +
"<span>Request Price</span> <input type='text' name='budget' value='{{names.budget}}' ng-model='editable.budget'><br/>" +
"</div>"+
"<div class='modal-footer'>" +
"<button type='button' class='close' ng-click='cancel()'>cancel</button>"+
"<button type='button' class='close' ng-click='update()'>update</button>"+
"</div>";
$scope.edit = function(data) {
var modalInstance = $uibModal.open({
template:templateModal,
controller: managementModal,
resolve: {
items: function() {
return data;
}
}
});
modalInstance.result.then(function(test){
console.log(test); // the result is undefined
});
};
var managementModal = function($scope, $http, $uibModalInstance, items){
$scope.cancel = function(){
$uibModalInstance.dismiss('cancel');
};
$scope.names = items;
$scope.editable = items[0];
console.log($scope.editable); // the result is undefined
$scope.update = function(){
$uibModalInstance.close();
};
};
});
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<meta charset="utf-8" />
<title>AngularJS Plunker</title>
<script>document.write('<base href="' + document.location + '" />');</script>
<link rel="stylesheet" href="style.css" />
<script data-require="angular.js@1.5.x" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.11/angular.min.js" data-semver="1.5.11"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script>
<script src="app.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body ng-controller="MainCtrl">
<table>
<tr ng-repeat="x in names">
<td ng-model="id">{{x.id}}</td>
<td>{{x.reg_date}}</td>
<td><button id="{{x.id}}" ng-click="edit(x)">edit</button></td>
<td>{{x.approval}}</td>
<td>{{x.status}}</td>
<td></td>
<td>{{x.orderer}}</td>
<td>{{x.creator}}</td>
<td>{{x.production_type}}</td>
<td>{{x.date}}</td>
<td>N/A</td>
<td><input type="checkbox" id="firstrequest_{{x.id}}"></td>
<td>{{x.budget}}</td>
</table>
</tr>
</body>
</html>
/* Put your css in here */