A brief overview of using element in an AngularJS directive, and how to target one without jquery, and also how to use replace and compile function
How are you typing into a second window and having that markup be injected into a string into your first window in WebStorm? Looks really nifty.
Alt-tab > Edit HTML fragment
I don't get the 'this.link' 'return link' logic. Why do we assign link like this.link but then refer to it in compile section like just 'link'?
I updated the code to show the proper "var link" approach (I had this corrected with an overlay on YouTube, but missed it in migrating the videos).
This approach is simply a convenience, nothing more. You can leave the link function as an anonymous function "link: function(){...}" if you'd like. The only tricky part is that a compile function returns a link function, so using compile (which is an edge case) will look much different than the standard way of just using "link: function()" on a directive definition object".
You were probably just demoing features but this approach should not be used in actual app as directive function is not executed repeatedly. And having multiple instances of directive breaks this example. Am I correct?