This works for me (server-side validation example):
AngularJS: integrating with server-side validation
But, I decided to ask additional question.
In that example we use unique-email directive:
<input type="email" ng-model="userEmail" name="userEmail" required unique-email/>
But when creating the directive, we use uniqueEmail:
app.directive('uniqueEmail', function($http) { ..
Why? Is it related somehow to name conventions / rules in names? How does angular know where to look and how to connect one to another?
I just wonder because when I used <input ... required uniqueEmail
it does not work. Until I typed "unique-email"
Same if I type:
app.directive('unique-email', function($http) {
It will not work until I type uniqueEmail
So there is no chance to use one style name when use directive and when define it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…