Some validation can only be done by interacting with a remote service, say a database. In these cases, the response from the service will be asynchronous. This brings in complication not only in working with model validation asynchronously but also in testing this functionality.
In our Admin User Form, we would like to check whether the e-mail address that a user is entering has already been taken. We will create a
uniqueEmail directive, which will check with our back-end server to find if the e-mail address is already in use:
<input ng-model="user.email" unique-email>
We use the
Users resource service to query the database for the e-mail addresses that are already in use. We need ...