"And it is for these attributes we've ridden from Texas to Tenessee."
- Django Unchained (2012)
We've already seen what attribute directives are for. They're used as attributes in your element, allowing you to tweak its looks or even behavior. The two built-in ones we covered (or rather left as an exercise) were ngStyle
and ngClass
Building a custom directive is a little tricky; but it gives you immense power and, speaking from a personal experience, saves you a lot of headache. I should mention that it's not the most essential of skills in that even without knowing this, you should be able to get by in your Angular ventures unimpeded. However, a mastery over custom directives would get you out of tough spots in ways you didn't think was possible. In my personal opinion, it's the single-most badass weapon you could have in your arsenal.
Enough buildup. Let's go.
The secret of these directives is that it let's you select specific elements, exactly like you do in CSS, and then modify them in ways CSS can never dream of. For example, let's do some modification on all our