Hi,
I have 2 fields Date and Time
In date field i am going to fill only date
in the same way In Time field i am going to fill only time
Ex:My input's are
Date:1-2-2019 Time:13:20
Date:2-2-2019 Time:12:24
Currently i am getting values like below in controller
Date:1-2-2019 Time:28/10/2019 13:20
Date:2-2-2019 Time:28/10/2019 12:24
In time it was taking by dafault today date
my excepted o/p
Date:1-2-2019 Time:1-2-2019 13:20
Date:2-2-2019 Time:2-2-2019 12:24
@{
Layout = null;
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="~/masters/angular.js"></script>
<script src="~/scripts/angular.js"></script>
<script src="~/scripts/angular.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/angular-utils-pagination@0.11.1/dirPagination.js"></script>
<script type="text/javascript">
var app = angular.module('MyApp', ['angularUtils.directives.dirPagination'])
app.controller('MyController', function ($scope,$http) {
$scope.Customers = [
{ Date: "1-1-2019", Time: '13:30'},
{ Date: "2-2-2019", Time: "12:24" },
{ Date: "3-3-2019", Time: "8:60" }];
//save or update code to database
$scope.Save = function () {
debugger;
var entry = {};
var details = new Array();
for (var i = 0; i < $scope.Customers.length; i++) {
var detail = {};
detail.Date = $scope.Customers[i].Date;
detail.Time = $scope.Customers[i].Time;
details.push(detail);
}
entry.details = details;
$http({
method: "Post",
url: "/Home/Save",
dataType: 'json',
headers: { "Content-Type": "application/json" },
data: '{entries: ' + JSON.stringify(entry) + '}'
})
};
});
</script>
</head>
<body>
<div ng-app="MyApp" ng-controller="MyController">
<table class="table table-bordered table-responsive">
<tr>
<th>Date</th>
<th>Time</th>
</tr>
<tbody dir-paginate="m in Customers|orderBy:sortKey:reverse|filter:search|itemsPerPage:10">
<tr>
<td><input type="text" ng-model="m.Date" /></td>
<td><input type="text" ng-model="m.Time" /></td>
</tr>
</tbody>
<dir-pagination-controls max-size="10" direction-links="true" boundary-links="true">
</dir-pagination-controls>
</table>
<button type="button" class="btn btn-success btn-sm" ng-click="Save()">
<span class="glyphicon glyphicon-plus"></span>
</button>
</div>
</body>
</html>
[HttpPost]
public ActionResult Save(DateEntry entries)
{
}
public class DateEntry
{
public List<Employee> details { get; set; }
}
public class Employee
{
public Nullable<System.DateTime> Date { get; set; }
public Nullable<System.DateTime> Time { get; set; }
}