angularjs my97 datepicker directive demo

app.directive('datePicker', function () {
    return {
        restrict: 'A',
        require: 'ngModel',
        scope: {
            minDate: '@',
        },
        link: function (scope, element, attr, ngModel) {

            element.val(ngModel.$viewValue);

            function onpicking(dp) {
                var date = dp.cal.getNewDateStr();
                scope.$apply(function () {
                    ngModel.$setViewValue(date);
                });
            }

            element.bind('click', function () {
                WdatePicker({
                    onpicking: onpicking,
                    dateFmt: 'yyyy-MM-dd',
                    minDate: (scope.minDate || '%y-%M-%d'),
                })
            });
        }
    };
});

你可能感兴趣的:(my97-datepicker,angular.js)