node.js - How to get a date value from angularjs form -
html
<div align="center" ng-controller="formctrl"> <form name="form" ng-submit="submitform()" novalidate> <input type="date" name="mydate" ng-model="mydate" value="mydate"/> </form> </div>
javascript
var app = angular.module('formexample', []); app.controller('formctrl', function ($scope, $http) { $scope.mydate = new date(); });
app.js
app.post('/', function (req, res) { var jtime = req.body.mydate; console.log(jtime); });
here result(console.log) shows undefined. how date value angular js form.
implement $scope.submitform
function making ajax post request using $http.post
:
app.controller('formctrl', function ($scope, $http) { $scope.submitform = function() { $http.post('/', {mydate: $scope.mydate}); }; });
Comments
Post a Comment