34 lines
986 B
JavaScript
34 lines
986 B
JavaScript
(function () {
|
|
'use strict';
|
|
angular
|
|
.module('View.Directive')
|
|
.directive('greaterThan', GreaterThanDirective);
|
|
|
|
//GreaterThanDirective.$inject = ['logService'];
|
|
|
|
function GreaterThanDirective() {
|
|
return {
|
|
require: '?ngModel',
|
|
scope: {
|
|
min: '@greaterThan'
|
|
},
|
|
link: function (scope, ele, attrs, ngModel) {
|
|
var min = parseFloat(scope.min);
|
|
|
|
if (!ngModel) return;
|
|
|
|
ngModel.$parsers.unshift(function (viewValue) {
|
|
var value = parseFloat(viewValue);
|
|
if (value > min) {
|
|
ngModel.$setValidity('greaterThan', true);
|
|
return viewValue;
|
|
} else {
|
|
ngModel.$setValidity('greaterThan', false);
|
|
return undefined;
|
|
}
|
|
});
|
|
}
|
|
};
|
|
}
|
|
}());
|