Set DateTime in DateTimePicker on Button Click using AngularJS in ASP.Net MVC

Last Reply 10 months ago By dharmendr

Posted 10 months ago


I have one table with records

Id     Date

1     12-02-2019 13:23:43

Currently my requirement is that after clicking of edit button need to display datetime on textbox.

currently in my case after clicking of edit button it was displaying only date

Implement DateTimePicker in AngularJS

Could you please help me


<html xmlns="">
    <script type="text/javascript" src=""></script>
<link rel="stylesheet" type="text/css" href="angularjs-datetime-picker.css" />
<script type="text/javascript" src="angularjs-datetime-picker.js"></script>
    <script type="text/javascript">
        var app = angular.module('MyApp', ['angularjs-datetime-picker'])
        app.controller('MyController', function ($scope, $http, $window,myService, $filter) {
            function GetEmployees() {
                $scope.employees = [];
                    method: 'Get',
                    url: '/Home/GetAll'
                }).success(function (data, status, headers, config) {
                    $scope.employees = data;
                }).error(function (data, status, headers, config) {
                    $scope.message = 'Unexpected Error';
   function ConvertJsonDateToDateTime(date) {
       var parsedDate = new Date(parseInt(date.substr(6)));
       var newDate = new Date(parsedDate);
       var month = ('0' + (newDate.getMonth())).slice(-2);
       var day = ('0' + newDate.getDate()).slice(-2);
       var year = newDate.getFullYear();
       return new Date(year, month, day)
   $scope.Edit = function (e) {
      var getData = myService.getemps(e.Id);
      getData.then(function (s) {
          $scope.e =;
          $scope.Id = e.Id;
          $scope.Date = ConvertJsonDateToDateTime(e.Date);
      }, function (msg) {
          $scope.msg =;
app.service("myService", function ($http) {         
    this.getemps = function (Id) {
        var response = $http({
            method: "post",
            url: "/home/getempByNo",
            params: {
                id: JSON.stringify(Id)
        return response;
    <div ng-app="MyApp" ng-controller="MyController">
       Date TimePicker:<input datetime-picker date-format="yyyy-MM-dd HH:mm:ss" ng-model="Date" />
            <table class="table table-bordered table-hover table-striped">
                <tbody ng-repeat="e in employees">
                        <td><a ng-click="Edit(e.Id)" href="">Edit</a></td>


This question does not have replies that have been liked.