For a WebApi2 service that returns json values ββas follows:
{ id: 1109, effectiveDate: "2014-10-05T00:00:00", // the date is a string (newtonsoft.json) text: "Duis et rhoncus nibh. Cras rhoncus cursus diam", fundSource: "Test" }
I need a date to be displayed in brackets angular / bootstrap / .
I need to convert the date to yyyy-mm-dd format (no time) when binding to an input box. Just a pointer to some documentation explaining how to correctly sort dates from API to angular. I am sure that effectiveDate should be Date , not string .
<input class="form-control" type="text" name="effectiveDate" ng-model="consultation.effectiveDate" data-date-picker="yyyy-mm-dd" placeholder="Date" />
For completeness of service, returning json values ββlooks like this:
app.factory('Service', ['$http', '$location', '$interpolate', function ($http, $location, $interpolate) { return { get: function (account) { var url = 'api/consultations/{account}'; return $http .get(Api.format(url, { account: account })) .then(function (response) { return response.data; }); } }; }]);
The controller method calls this as follows:
service.get($scope.urlData.account).then(function(consultations) { $scope.consultations = consultations; });
source share