简体   繁体   中英

Angular bootstrap datepicker start date function

I have this:

            <a href="#" data-bs-datepicker
               data-date-startDate="{{startDate(task)}}" data-ng-model="task.plannedEndDate"
               rel="tooltip" data-placement="left"
               title="${message(code: "dashboard.todosAndTasks.hint.editDueDate")}">
                {{task | dateIndication}}
            </a>

and the function:

    $scope.startDate = function(task) {
        var d = new Date(task.plannedStartDate);
        var curr_date = d.getDate();
        var curr_month = d.getMonth() + 1; //Months are zero based
        var curr_year = d.getFullYear();
        var m = curr_date + "/" + curr_month + "/" + curr_year;
        console.log(m);
        return m;
    };

The function gets called, I get a correct date-string logged in my console, but in the datepicker js, if I log the date received by this 'startDate' parameter, it's the actual string "{{startDate(task)}}" -> startDate automatically set to "today".

Why in the world does this happen?

++ only using data-date-startDate="startDate(task)", passess the string "startDate(task)" to the datepicker.js

Why!!?

Try this:

<a href="#" data-bs-datepicker
           start-date="{{startDate(task)}}" data-ng-model="task.plannedEndDate"
           rel="tooltip" data-placement="left"
           title="${message(code: "dashboard.todosAndTasks.hint.editDueDate")}">
            {{task | dateIndication}}
 </a>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM