I have problem when i select any checkbox only selected row data should visible inside the model dialog.
- But i my case when i do click on process(which calls model dialog) where all data coming either i will select or not.
- But after click on save data button (which is inside the model) data is coming proper what i selected.
- But I have to show data before click on save data button.
html code
<div class="row">
<div class="col-md-12">
<h1>OMR Duplicate Students List</h1>
<table id="example" class="table">
<tr>
<th><input type="checkbox" ng-click="vm.selectAll()"
/></th>
<th>Name</th>
<th>Mobile</th>
</tr>
<tr ng-repeat="data in vm.data">
<td><input type="checkbox" ng-model="data.selected"class="duplicateRow" /></td>
<td></td>
<td></td>
</tr>
<tr>
<tr>
<button type ="submit" class="button pull-right" data-toggle="modal" data-target="#myModal">Process</button>
</tr>
</table>
<table class="table">
<tr>
<td colspan="4">
<pagination page-number='' page-count="" total-records="" api-url="duplicate-student"></pagination>
</td>
</tr>
</table>
</div>
</div>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">These Recods You are Selected</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<!-- <div ng-if="data.selected === 'true'"> -->
<table id="example" class="table">
<tr>
<th>Name</th>
<th>Mobile</th>
</tr>
<tr ng-repeat="x in vm.data">
<td></td>
<td></td>
</tr>
</table>
<!-- </div> -->
</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" ng-click="vm.process()">Save Data</button>
</div>
</div>
<!-- /.modal-content -->
</div>
Java script code
function StudentDuplicateAccountController($scope, ApiService, $routeParams, $http, $location, $timeout) {
var vm = this;
var page = $routeParams.page || 1;
vm.data = [];
ApiService.getAll('student-duplicate-account?pageCount=5&pageNumber=' + page).then(function(response) {
vm.data = response.data.records;
vm.pageNumber = response.data.pageNumber;
vm.totalRecords = response.data.totalRecords;
vm.pageCount = response.data.pageCount;
//$scope.renderpagination = true;
});
vm.selectAll =function(){
angular.forEach(vm.data, function(data){
if (data.selected) {
data.selected = false;
} else {
data.selected=true;
}
});
}
vm.selectedUsers = [];
vm.process = function() {
vm.selectedUsers.splice(0, vm.selectedUsers.length);
vm.data.forEach(function(studentData){
if(studentData.selected) {
vm.selectedUsers.push(studentData);
}
})
console.log("selectedUsers:::::::::"+JSON.stringify(vm.selectedUsers))
if (vm.selectedUsers.length === 0) {
toastr.info('Selected atleast one record.', null, {
timeOut: 3000
})
return;
} else {
ApiService.save('student-duplicate-account',vm.selectedUsers).then(function(response) {
vm.mobileNumber = vm.data.mobileNumber,
vm.schoolId = vm.data.schoolId,
vm.tenantId = vm.data.tenantId,
vm.classId = vm.data.classId
toastr.success('Selected records are marked for re-processing.. Please try some time later..', 'Success', {
timeOut: 3000
})
}, function(err) {
toastr.info('duplicate student data fail <br> ' + err.data.message, null, {
timeOut: 5000
})
});
}
}
Aucun commentaire:
Enregistrer un commentaire