简体   繁体   中英

unable to call jquery datetimepicker function in custom directive

I have made a custom directive in angularJs which is used to show datetimepicker.

app.directive("timePicker", function() {
            return {
                restrict: "A",
                link: function(scope, elem, attrs) {
                    //On click
                    $(elem).click(function() {
                        $(this).datetimepicker();
                    });
                }
            };
        });

used it like this in html

<div>
            <input type="text" name="basic_example_1" id="basic_example_1" value="" class="hasDatepicker" 
            time-picker>
        </div>

I am using following js files.

<script src='appResources/js/jquery-ui-sliderAccess.js'></script> 
<script src='appResources/js/jquery-ui-timepicker-addon.js'></script>
<script src='appResources/js/jquery-ui-timepicker-addon-i18n.min.js'></script>
<link href="appResources/css/jquery-ui-timepicker-addon.css" rel="stylesheet" />

I am referring from this site to get datetimepicker here

try to use only:

jquery-ui-timepicker-addon.js

and check console log, maybe there are errors

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