Wednesday, November 28, 2012

About those directives

Turns out we forgot to publish September's meetup videos from the Mountain View meetup.  Yikes!  Well, better late than never.

Actually, this is some of our best content to date.  For the first time, Miško Hevery demystifies AngularJS Directives.  If you've struggled with some of the concepts and reasons behind writing directives, this one is for you.

As a perfect follow-up, Vojta Jína gave a presentation on writing unit tests for directives and discusses techniques to make them run quickly.


For folks just starting out with Angular, Igor Minar walked folks through the basic features of Angular in writing the ubiquitous ToDo application.


At the end, Dean Sofer (aka ProLoser), presented JobVite - a cloud-based recruiting platform written in AngularJS.



10 comments:

  1. Wow this is an amazing fountain of inspiration, thank you !! i will put this on practice right now.

    ReplyDelete
  2. "I see a lot of confusing people... And i like when peaple are happy!"
    Ive read "Developer Guide / directive" and it's not best doc at site, its realy needs diagrams/video and may be completle rewrite to simplify article. 26 comments already.
    By the way: DISQUS module on docs.angularjs.org/guide/ got broken on swithing articles.
    Console log full of "DISQUS assertion failed: Unsafe attempt to redefine existing module"

    And Angular is realy rocks!

    ReplyDelete
  3. At some point Misko says that it's probably a bad idea to create a directive for a modal html dialog. Why is this a bad idea?

    ReplyDelete
  4. Hey Andy,

    This is Misko's opinion on design. As the modal dialog doesn't take up a specific place in the rest of the application, does it make sense for it to live in any particular template? Misko was arguing that the answer is 'no', that this is one case where some part of the UI is not a good fit for directives but that instead you might write this as a service that could be called to create the modal when appropriate.

    ReplyDelete
    Replies
    1. Hi Brad,

      Thanks for the reply. It definitely makes sense, but I'm a little bit confused though.

      From what I understood (not necessarily from this video) there should be no DOM manipulation in controllers. This is obviously good practice as it keeps them easier to test.

      As a result we've been putting all our jQuery code in directives (including our modal dialog for that matter :))
      Alternatively, we could also put some of this code in separate services, but where do I call these methods?
      Because there is no declarative way to call these services, I think we can only call them from within the controller which is not a good solution for the reasons that we stated earlier... unless we inject mock implementations while testing (e.g. a ModalMockService)

      Unfortunately this stilll doesn't offer a good solution for the transcluded content of my modal dialog directive.

      I'm sure there are a lot more use-cases that fall into the same category. An elegant solution without directives would be most interesting because it still requires quite a lot of effort and expertise to create directives.

      Thanks in advance,

      Best regards,
      Andy.

      Delete
  5. Is the code for Vojta's presentation being hosted anywhere? Would love to peruse it...

    ReplyDelete
  6. Last video seems to be marked as private

    ReplyDelete
  7. Fantastic! Just watched the first one about directives so far, but it does a great job at explaining!

    ReplyDelete
  8. Excellent tutorials. I just love Angular!!

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete

Note: Only a member of this blog may post a comment.