I actually haven't used jQuery UI much, and been just tooling around with AngularJS. That's why when a recent project came up at work which had the typical ASAP schedule, I thought: "Let's put AngularJS to work!" Also, the application I was building was an internal tool, so it could be a little rough around the edges and customers/clients wouldn't make fun of me if something wasn't quite right.
So....low risk, let's dive right into Angular! I also had the assumption that if Angular was all I thought it was cracked up to be, it would save me lots of time, and allow me and others very nice visibility to how my project worked so they could make updates very simply, right in the HTML.
Boy was I right. I felt like Angular sped things up and gave me what I wanted, with a nice easy, predictable structure.
What I didn't expect was that I'd be mixing jQuery UI in. What I REALLY didn't expect was how SLICK Angular makes it to mix things like jQuery UI in.
The Problem: I want to drag something to a drop zone #
Pretty simple right? Of course, of course I can write this from scratch in Javascript. And if I wrote it from scratch, I'd probably cut corners and.....not necessarily make it all fancy with tags and attributes for my Angular setup. No, I'd probably loop through all the elements in my list that I'd like to drag, attach onmouseout, onmouseover, and onmousemove listeners. And then keep a separate list of all my drop zones and check positions of things while they are being dragged.
PAIN IN THE BUTT. I don't mind doing cool things by hand, but things that are readily available elsewhere? Boring. So I turn to Google and type in "AngularJS drag and drop". I came across this gist:
https://gist.github.com/codef0rmer/3975207
Given what AngularJS is supposed to do, I didn't expect to find any functionality in Angular to support drag and drop. Indeed I didn't, but what this gist shows is the ability to declare your own attributes in HTML and have Angular process them, adding your own logic to what those things do. THAT IS SLICK!
Angular Directives #
So let's take "draggable" and "droppable" as our primary examples for an Angular directive.
In our HTML, create a div with your own custom attribute on it: