I'm attempting to add ng-minlength and ng-maxlength to a form input field. There is something strange happening. When the a number is entered is less than the min-length it disappears and is never added to the model.
However if you past in a number over 13 digits it renders but is not added to the model.
app.directive('cmNumber', ['$compile', function ($compile) {
return {
restrict: 'A',
compile: function (element) {
var onlyNumbers = /^\d+$/;
element.attr('ng-minlength', '13');
element.attr('ng-maxlength', '19');
element.attr('ng-pattern', onlyNumbers);
element.attr('placeholder', '123456789112345');
element.removeAttr('cm-Number'); //remove the attribute to avoid infinite loop
return function (scope, element) {
$compile(element[0].form)(scope);
};
}
};
}]);
plunker here http://plnkr.co/edit/G4DaGSt190NTdaognJrJ?p=preview
compilerather than adding these values to the template?