0

I want to call datepicker using angularjs. I have tried with some piece of code, can someone help me on what is missing. In html tag getting "unknown attribute datepicker". Appreciate you help.Thanks.

<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);
            }
        }
    });
Thiyagarajan
  • 327
  • 1
  • 6
  • 21

1 Answers1

0

Like Pankaj mentioned in the comments, sounds like you are missing some file. Make sure you are including everything in the right order. Simple things like adding jQuery before jQuery UI might be your answer.

Working example

Peter Han
  • 547
  • 1
  • 6
  • 13