I have Datepicker directive in my application. There's today button on top as well. Well, now I want to show todays's date in the text box when one clicks on Today. How can I acheive that?
-
please refer to this fiddle to achieve that jsfiddle.net/e2kddjcbRizky Ariestiyansyah– Rizky Ariestiyansyah2016-01-03 03:41:46 +00:00Commented Jan 3, 2016 at 3:41
-
@ariestiyansyah : Where in your jsfiddle code does it do that? I only see the directive which does have this functionality embedded in it, but I don't see what the OP asked for, which is a button not related to the datepicker directive that sets the date to today.o4ohel– o4ohel2016-01-03 03:52:59 +00:00Commented Jan 3, 2016 at 3:52
Add a comment
|
1 Answer
Markup:
<button class="btn" ng-click="today()">Today</button>
JavaScript
$scope.today = function() {
$scope.dt = new Date();
};
Where "$scope.dt" is the ng-model of your datepicker directive.
1 Comment
Chanki Ahuja
Today button is inbulit into the datepicker..its not which is created by us. When clicked, it highlights the current date. So we need to change its current functionality. Its fucntionality is in the standard jquery of Datepicker So find it difficult to show the date in the textbox when clicked on today.