AngularJS Validation on ng-show not working on when select2 is added -
this question has answer here:
i using select2 of bootstrap have search dropdown menu problem validation not working. working without select2 not working , message shown always.
<div class="form-group" ng-class="{ 'has-error' : addemployee.formadd.pos.$invalid && !addemployee.formadd.pos.$pristine }"> <label>position</label> <select name="pos" id="pos" ng-model="addemployee.employee.employee_positionid" class="form-control select2" required> <option ng-repeat="option in addemployee.position" value="{{option.position_id}}">{{option.position_name}}</option> </select> <p ng-show="addemployee.formadd.pos.$invalid && addemployee.formadd.pos.$dirty && addemployee.formadd.pos.$touched && addemployee.formadd.pos.$error.required" class="help-block">position required.</p> </div>
you can still validate controller after trying save form using:
if ($scope[formname].$invalid) { e.preventdefault(); angular.foreach($scope[formname].$error, function (field) { angular.foreach(field, function(errorfield){ errorfield.$settouched(); }); }); /*add notification user here*/ return; }
Comments
Post a Comment