我使用以下指令检查过去的月份/年份是否过去?我在看ccinfo.month,ccinfo.year
模型。
angular.module('app').directive('cardExpiration', function() {
var directive = {
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
scope.$watch('[ccinfo.month,ccinfo.year]', function(value) {
ctrl.$setValidity('invalid', true)
if (scope.ccinfo.year == scope.currentYear &&
scope.ccinfo.month <= scope.currentMonth
) {
ctrl.$setValidity('invalid', false)
}
return value
}, true)
}
}
return directive
})
当前月August
未能check
。上个月July
次传球和September
次传球。为什么这段代码说current month as invalid?