how to select a day in a datepicker using AngularJS

2

Good, I am doing a project with AngularJS 1.6 and I would like to save in a variable of the Scope on a specific day and that when it is visible, the day is marked in the calendar without having to do anything. I assumed that using the scope variable in the ng-model would already be there, but the fact is that it is not doing anything to me.

The code is very basic:

<datepicker date-format="dd/MM/yyyy" date-week-start-day="1" ng-model="dt">
   <input ng-show = "false" name="day" type="text" class = "smallInputCrear" ng-model="dt">
</datepicker>

and in the Controller:

$scope.dt = new Date();

I would be very grateful if someone could help me out. Thanks.

    
asked by Javi 05.09.2017 в 16:38
source

2 answers

0

I assume, by the lines of code, that you are using the component of angular-datepicker . In the documentation indicates that the ng-model must be put to the tag <input> no to <datepicker> . It also indicates that to mark a day by default, you have to use date-set="{{date}}"

    
answered by 07.09.2017 / 12:14
source
1

The correct code would be the following, in the driver :

$scope.date = new Date();

and HTML :

<datepicker date-format="yyyy-MM-dd">
    <input ng-model="date" type="text"/>
</datepicker>
    
answered by 07.09.2017 в 12:27