当前月份是无效的angularjs

时间:2016-08-26 20:53:06

标签: javascript angularjs

我使用以下指令检查过去的月份/年份是否过去?我在看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?

0 个答案:

没有答案