<div class="form-group"> <label class="sr-only">@Labels.firstName:</label> <input class="form-control" name="firstName" id="firstName" type="text" ng-maxlength="100" ng-required="validationRequired" placeholder=@Labels.firstName data-ng-model="currentData.firstName"> </div> <div class="form-group"> <input class="form-control" type="text" size="1" ng-maxlength="100" placeholder=@Labels.middle data-ng-model="currentData.middleName"> </div> <div class="form-group"> <input class="form-control" type="text" ng-required="validationRequired" name="lastName" id="lastName" ng-maxlength="100" placeholder=@Labels.last data-ng-model="currentData.lastName"> </div> <div class="form-group"> <input class="form-control" type="text" placeholder=@Labels.suffix data-ng-model="currentData.suffix"> </div> <div class="form-group"> <div class="col-md-12 field-validation-error" > <span ng-show="validationRequired && ((currentData.firstName.length == null) || (currentData.firstName.length === 0))"> @String.Format(Messages.isRequired, Labels.firstName) </span> <span ng-show="currentData.firstName.length>100"> @String.Format(Messages.cannotExceed, String.Format(Labels.firstName, "1"), 100) </span> </div> </div>Instead of that, I want to have the 'normal' way of fields validations like we have in the forms, e.g.
<div class="col-md-7"> <input type="text" name="nickname" id="nickname" ng-model="currentAccount.acctName" class="form-control" ng-maxlength="10" ng-model-options="{allowInvalid:true}" placeholder="@Labels.nickname" required data-sm:focus="isNew" /> <div class="field-validation-error"> <span ng-show="form.editAccountGeneral.nickname.$error.required && form.editAccountGeneral.nickname.$dirty"> @String.Format(Messages.isRequired, Labels.nickname) </span> <span ng-show="form.editAccountGeneral.nickname.$error.maxlength && form.editAccountGeneral.nickname.$dirty"> @String.Format(Messages.cannotExceed, Labels.nickname, "10") </span> </div> </div>The directive does have the following (e.g. name of the form is required):
app.directive('smContact', ['resourceFactory', function (resourceFactory) { return { restrict: 'E', scope: { currentData: '=', isNew: '=', contactLabel: '@?', validationRequired: '=', showChooseContact: '=', form: '=' },So, my question is - how to use that 'form' in the fields validations inside the template?