I'm very new to Angular, so I'm sorry if this is silly.

Here's my form definition:

<form
    class="form-horizontal"
    name="patientForm" 
    method="post"
    novalidate >
    

    <div class="form-group has-feedback" 
         ng-class="{'has-error': patientForm.firstName.$invalid && 
patientForm.firstName.$dirty}">
        
        <label class="col-sm-2 control-label">First Name</label>
        <div class="col-sm-3">
            <input 
                name="firstName"
                ng-model="formData.firstName"
                type="text"
                class="input-sm form-control"
                placeholder="First Name"
                value="#rc.patient.getFirstName()#"
                required>
        </div>
        
        <!--- Error Div --->
        <div class="input-sm" ng-show="patientForm.firstName.$dirty && 
patientForm.firstName.$invalid">
            <span class="help-block" 
ng-show="patientForm.firstName.$error.required">First name is 
required</span>            
        </div>
    </div>

</form>

And here are my two questions:

1)  Is it okay to have a class and ng-class attribute on a tag, as I do on 
the input tag?

2)  Is there an easy way to declare a more generic function to do the 
'has-error' bit in a function?  Something I could use for all my required 
form vars?  I know this is doable, I'm just having a hard time seeing it.

-- 
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