My question is when I click the edit link in the table model-dialog want to open and its value should be assigned in there field. Here dialog will opening but the value will not getting initialized.
<div ng-app="myapp" ng-controller="myctrl">
<form method="POST" action="Projects" >
<div class="modal fade" id="update" role="dialog" >
<div class="modal-dialog">
<label for="Project_Id"> Project Id</label>
<input readonly="readonly" ng-model=project_id class="form-control"
id="project_id" value="" />
</div>
</div>
</form>
MY question is when I click the edit link in the table model-dialog want to open and its value should be assigned in there field. Here dialog will opening but the value will not getting initialized.
<table>
<thead><tr><td> Edit </td></tr></thead>
<tbody>
<tr ng-repeat="values in records ">
<td>
<a data-toggle="modal" ng-model=values.projectId
ng-href="#update"</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
var app = angular.module('myapp', []);
app.controller('myctrl', function($scope, $http) {
$http.get('Projects').success(function (data) {
$scope.records = data;
$scope.project_id=$scope.data.projectId;
// $scope.project_id="some value" ...if i remove this comment it is working properly some value will be shown, but I need particular record data.projectId should be displayed
});
</script>
答案 0 :(得分:0)
尝试以下方法:
点击你的标签,如下:
<a data-toggle="modal" ng-model= values.projectId ng-click="viewRecord(values.projectid)"></a>
在角度控制器中:
$scope.selected = {
records:[]
};
$scope.viewRecord = function(recordId){
$scope.selected.records.push(record)
}
然后在你的模态:
<div ng-repeat="r in selected.records">
<div><input type="text" value="r.projectId"></div>
</div>
答案 1 :(得分:0)
<table>
<thead><tr><td> Edit </td></tr></thead>
<tbody>
<tr ng-repeat="record_values in records ">
<td>
<a data-toggle="modal" ng-click='disp(record_values)'
ng-href="#update"</td>
</tr>
</tbody>
</table>
</div>
<script type="text/javascript">
var app = angular.module('myapp', []);
app.controller('myctrl', function($scope, $http) {
$http.get('Projects').success(function (data) {
$scope.records = data;
$scope.disp=function( record)
{
$scope.project_description=record.projectId;
};
});
</script>