关于my97Datepicker日期控件与AngularJS的ng-mode赋值问题

鉴于上述情况,我们可以自己定义一个日期指令并利用my97Datepicker的onpicked事件来赋予ng-mode值。

(function(){
    var DateDirectives = angular.module('DateDirectives', []);
    DateDirectives .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);
	                });
	            }
	            //function onpicked(dp){
	            	//$(dp.el).validationEngine('validate');
	            //}
	            function oncleared(){
	            	scope.$apply(function () {
	                    ngModel.$setViewValue("");
	                });
	            }
	            
	            element.bind('click', function () {
	                WdatePicker({
	                    onpicking: onpicking,
	                    oncleared: oncleared,
	                    onpicked: onpicked,
	                    dateFmt: (attr.datefmt || 'yyyy-MM-dd')
	                    //minDate: (scope.minDate || '%y-%M-%d'),
	                })
	            });
	        }
	    };
	});
})();


你可能感兴趣的:(关于my97Datepicker日期控件与AngularJS的ng-mode赋值问题)