One of the tasks that comes up fairly frequently in application development is ensuring that a specific value is unique as a user enters it into a form. For example, you may have a user name or email that is entered by a user that you want to ensure is unique before allowing them to submit the form. There are a variety of ways to handle that type of scenario including making standard Ajax calls directly from an AngularJS controller, but if you find yourself performing this type of task over and over it may be time to consolidate your code and make a re-useable component. Enter directives – the perfect way to add “unique value” functionality into a form.
In this post I’m going to walk through a simple unique value directive and show how it can be used. Along the way I’ll also discuss a few aspects of validation in AngularJS as well.
Your new post is loading...