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.
From here:
Directives have camel cased names such as ngBind. The directive can be invoked by translating the camel case name into snake case with these special characters :, -, or _. Optionally the directive can be prefixed with x-, or data- to make it HTML validator compliant.
So, yes it is an angular convention.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With