I have a datepicker on my angularJS WCFrest project
i get the data using
<div class="col-md-4">
<input id="txtOldDate" type="date" class="datepicker" ng-model="oldDate" />
</div>
but the data that acquired is too complex when i get the data
Fri Dec 16 2016 00:00:00 GMT+07 (SE Asia Standard Time)
i just want to get the value like on the date picker interface
12/16/2016
this is my controller.js
$scope.SearchApproval = function(employeeID, oldDate, newDate, departemen, approver) {
var promiseGet = GetApproval.GetApprovalData($scope.employeeID, $scope.oldDate, $scope.newDate, $scope.departemen, $scope.approver);
//GetApprovalData();
promiseGet.then(function(pl) {
$scope.GetApprovalData = pl.data
},
function(errorPl) {
console.log('Some Error in Getting Records.', errorPl);
});
}
is there any way to format the result?
i already try $filter
$scope.oldDate = $filter('date')(new Date(dateString), 'yyyy-MM-dd');
but it give me this error
Error: [ngModel:datefmt] Expected
2016-12-20
to be a date
Take a look at this Angular Moment Js and Moment Js it might be helpful.
You can convert this as the below using moment js
$scope.oldDate = moment(dateString).format("YYYY-MM-DD");
To use this you have to add Angular moment in your project and which is explained in above link how to add using nuget or bower or npm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With