AngularJS Directives

By on

AngularJS Directives

Recently PacktPub sent me a copy of their book AngularJS Directives. As the title suggests you will get 110 pages about AngularJS directives if you buy it. A lot of people consider writing directives one of the most complicated tasks you can have with AngularJS. It is not so wrong to say that. Directives are extremely powerful but can become tricky to write. I am not exactly new on that part of AngularJS and so I was unsure if this book what give me something in addition.

Surprisingly this book gave me a lot. It is a well written which and explains almost any aspect of directives I can imagine. If you struggle with the AngularJS docs (which is almost certainly the case) you should definitely look at the book. Alex Vanston wrote it for people who managed their first steps with AngularJS but need more. Although there is a little introduction you should be able to read JavaScript, maybe even know what jQuery is and absolutely should have made some experiments with AngularJS. It is not a book for beginners.

Vanston explains why we all need Directives and quickly moves on to answer four important questions:

  • what is the difference between compile and linking phase?
  • how do I work with the scope?
  • how do I share my directive data with controllers?
  • what the heck is transclusion?
I consider these questions the key to understand AngularJS directives and Vanston does a great job explaining them. It took me a while to understand all that from the docs and I could have saved so much time with that book.

My personal biggest win with the chapter on unit testing. I had a long time the idea that directives were so hard to test that it wouldn't make sense. Now I look at this problem a bit different, thank to Vanston.

I like the books writing style and enjoyed the author used real world examples (like Autocomplete or working with the jQuery Masonry plugin). Unfortunately some of the code examples became a bit unreadable. On a few places there are too much comments in the code and too much line breaks. In addition there is no "code high-lightening" and something like that. It is not exactly unreadable, but sometimes it will take its time to identify the things.

If you are an aspiring AngularJS developer you should not be troubled by some formatting and buy the book. It is focused and an easy read which will help you a lot to improve your AnguarJS skills.

Tags: AngularJS, Review