How about creating applications without controllers? How about writing independent modular features?
Today we will cover the last two steps on the progression. We added some basic validation (Part1), then we created a validation on a single form control (Part1), we raised the bet creating a custom validation over a complex object (Part2). We took some distance and refactored our code to make it a reusable component (Part3). And now we will make sure we handle multiple instances and its multiple errors in a semantic efficient fashion that provides the user a much better experience.
In this delivery, we are going to refactor our birth date validation and html into a semantic reusable component. If you would like to revisit out of the box validations, creating a custom validation over a single input, read Part 1 and if you would like to revisit creating validations over complex objects go over Part 2.
I ll take you through a 6 steps progression on custom validations. We ll go from out of the box Angular provided validations to reusable directives components. In this article, we’ll cover out of the box validations and unit testing/creating our first custom validation as a directive.
Going back to our last post related to best practices and roles in AngularJS, let's talk a little bit more about this showing a really small example.
Lets talk about best practices and roles in AngularJS. A controller is the middle man. Its main role is to talk to the Service to get the model and then make sure this model is available to our presentation layer(html). Even in large applications, the controller should be small, compact and dumb!