javascript - Unable to bind the Calendar value in Angular js -
i new in angular js , trying bind value of calendar date jquery calendar picker not binding accept date other fields binding.
here html
<input id="company" name="company" ng-model="user.company" type="text" placeholder="" class="form-control" required> <input type="text" name="exdate" ng-model="user.exdate" id="exiprydate" placeholder="dd-mm-yyyy" class="form-control" required>
here jquery code
$(function () { $("#exiprydate").datepicker({ dateformat: 'dd-mm-yy' }); });
here controller :
var app = angular.module('myapp', []); app.controller('admincontroller', function($scope, $http, $location) { $scope.submitloginform = function(isvalid, user) { console.log($scope.user); });
here snap of calendar can pick date : enter image description here
simply create directive datepicker.. this:
angular.module('myapp').directive('datepicker', function() { return { restrict: 'a', require: 'ngmodel', scope: { ngmodel: '=' }, link: function(scope, element, attrs, ngmodelctrl) { element.datepicker({ onselect: function(date) { ngmodelctrl.$setviewvalue(date); } }); } }; });
and html be:
<input date-picker type="text" ng-model="mydate" />
Comments
Post a Comment