1

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?

2
  • please refer to this fiddle to achieve that jsfiddle.net/e2kddjcb Commented 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. Commented Jan 3, 2016 at 3:52

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.