I have this code:
<label>
Text {{ ers.verify(cos.contentForm.contentText, 5) }}
</label>
<textarea id="contentText"
name="contentText"
ng-minlength="5"
ng-model="cos.content.text"
ng-required="true"></textarea>
and a verify function:
verify = function (field, min, pattern) {
if (pattern == undefined) {
pattern = false;
}
if (angular.isDefined(field)) {
if (field.$error.required) return "*";
if (min) {
if (field.$error.minlength) {
var msg = "> " + min + " char"
return msg;
}
}
}
return "";
}
Everything works and an appropriate message is given but one of my team is saying that it is wasting resources if I continuously check the value of the field.
Is there a better way to do this that would be more efficient. For example I was thinking to have the ng-change event call a function.