This is best illustrated with sample markup. It's extracted from a project that I'm working on:
The general idea behind this is that you need to set Bootstrap's 'has-error' class when loginForm's email field is invalid. Simple enough, right?
AngularJS introduces two issues that are present in the latest unstable version (1.2.0rc1). They could be in previous versions, but I didn't check.
- You must have quote marks around the name of the 'has-error' class in the ng-class expression.
- The input must be bound to the model by using AngularJS's ngModel directive
ng-class='{has-error: loginForm.email.$invalid}'
your JS will crash within AngularJS because it's an invalid expression.I have little idea why data binding is required. I suspect that AngularJS requires it because it expects you to use the field's contents somewhere else in your app.
No comments:
Post a Comment