【问题标题】:How to call the datepicker using Angularjs如何使用 Angularjs 调用日期选择器
【发布时间】:2015-11-05 19:01:31
【问题描述】:

我想使用 angularjs 调用 datepicker。我已经尝试了一些代码,有人可以帮助我解决丢失的问题。在获取“未知属性日期选择器”的 html 标记中。感谢您的帮助。谢谢。

<input ng-model="datePicker" id="txt_parentcrid" type="text" placeholder=":input" datepicker/>
   var app = angular.module("myApp", []);
    app.directive("datepicker", function () {
        return {
            restrict: "A",
            require: "ngModel",
            link: function (scope, elem, attrs, ngModelCtrl) {
                var updateModel = function (dateText) {
                    scope.$apply(function () {
                        ngModelCtrl.$setViewValue(dateText);
                    });
                };
                var options = {
                    dateFormat: "dd/mm/yy",
                    onSelect: function (dateText) {
                        updateModel(dateText);
                    }
                };
                elem.datepicker(options);
            }
        }
    });

【问题讨论】:

  • 它应该可以工作..如果你正确地包含了datepicker & jQuery..
  • @pankaj Parkar 我已添加 除了这个还有什么需要添加的吗?
  • 会建议阅读这个答案stackoverflow.com/a/29194068/2435473

标签: javascript jquery angularjs datepicker


【解决方案1】:

就像 cmets 中提到的 Pankaj 一样,听起来您缺少一些文件。确保您以正确的顺序包含所有内容。在jQuery UI 之前添加jQuery 之类的简单操作可能就是您的答案。

Working example

【讨论】:

    猜你喜欢
    • 2019-11-28
    • 1970-01-01
    • 2014-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-11
    • 1970-01-01
    • 2018-01-28
    相关资源
    最近更新 更多