angularjs - Best practise to format a hibernate date in angular -
what best way format time value of json objects (in milliseconds) date , render in view. reason angular seems not format therefore input field stays empty?
a hibernate entity returned json via rest.
entity account:
@entity @table(name = "account") @jsonignoreproperties(ignoreunknown = true) public class account extends baseentity implements serializable { private static final long serialversionuid = 1l; @column(name = "name") private string name; @column(name = "email") private string email; @temporal(temporaltype.timestamp) @column(name = "birthday") ...
rest ws:
@requestmapping(value = "upsert", method = requestmethod.post) public responseentity<account> upsert(@requestbody account account) { account response = accountaccess.upsert(account); return new responseentity<>(response, httpstatus.ok); }
angular account controller:
$scope.updateaccount = function(flow) { $http.post("rest/account/upsert", $scope.account) .success(function(response) { $scope.account = response; $localstorage.account = response; toaster.pop('success', "account saved", "your data succesfully saved.") }) .error(function(error){ toaster.pop('error', "account not saved", "your data not saved.") }) }
account html:
<div class="form-group"> <label class="col-sm-2 control-label">date</label> <div class="col-sm-10"> <div class="input-group date"> <input id="birthday" type="date" class="form-control" ng-model="account.birthday | date" datepicker-options="dateoptions" close-text="close" /> <span class="input-group-addon"><i class="fa fa-calendar"></i></span> </div> </div> </div>
Comments
Post a Comment