Angular Directive-My97Date

directive.js 内容如下

angular.module('NG', []).directive('ngdatepicker', function () {
    return {
        restrict: 'A',
        require: '?ngModel',
        link: function ($scope, $element, $attrs, ngModel) {
            $element.on('focus',function(){
                WdatePicker({
                    readOnly: true,
                    onpicked: function(){
                        $scope.$digest();
                    }
                });
            });
            $scope.$watch(function(){
                return $element[0].value
            }, function(newDate){
                eval('$scope.'+$attrs.ngModel+' = newDate;');
            });
        }
    }
});      

使用时需依赖jQuery及My97DatePicker,用法:

你可能感兴趣的:(Angular Directive-My97Date)