how to bind Bootstrap-datepicker element with angularjs ng-model?

后端 未结 11 745
囚心锁ツ
囚心锁ツ 2020-11-30 04:44

Here is the html for the date field :

11条回答
  •  时光取名叫无心
    2020-11-30 05:20

    I am using bootstrap 3 datepicker https://eonasdan.github.io/bootstrap-datetimepicker/ and angularjs, I had the same problem with ng-model, so I am getting input date value using bootstrap jquery function, below is the code in my controller, it's worked for me.

    Html

    
    

    Controller

    $(function() {
    
        //for displaying datepicker
    
        $('#datetimepicker').datetimepicker({
            viewMode: 'years',
            format: 'DD/MM/YYYY',
        });
    
        //for getting input value
    
        $("#datetimepicker").on("dp.change", function() {
    
            $scope.selecteddate = $("#datetimepicker").val();
            alert("selected date is " + $scope.selecteddate);
    
        });
    
     });
    

提交回复
热议问题