I think it's a great approach, and in fact, they are adding this to angular 
soon: https://github.com/angular/angular.js/issues/10036

Currently, I store the errors as an attribute on my model, then use a 
directive (my-form-errors) to handle the $validator piece.  Then in my 
view, I do this:

       <div class="form-group" 
ng-class="{'has-error':myForm.myfield.$invalid}">
            <label class="control-label">Field Label</label> 
            <input class="form-control" name="myfield" type="text" required 
ng-model="MyModel.myfield" my-form-errors my-model-errors="MyModel.errors"/>
            <div ng-messages="MyForm.myfield.$error" >
                <div class="has-error" ng-message="required">This field is 
required</div>
                <div class="has-error" ng-message="panelerrors"><span 
ng-repeat="error in MyModel.errors.myfield">{{error}}<br></span></div>
            </div>
        </div>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to