My face should have loaded here :(
Erik Farmer
Programmer

Diving into Directives

While I was working on a backend service in flask I was looking at some frontend code and though to myself "there has got to be a better way!"

With changes to tech the "right way" to do something changes as well. I saw a webform that had a handful of dependencies that I was pretty sure were included in AngularJS and figured porting that code to would be a great way to expose myself to Angular more (our stack is Angular/Flask so learning it would allow me to assist on front end issues). The first step was incorporating Angular input validation with Twitter Bootstrap input highlighting. My first stab was along the lines of this blog post. However I went with a slightly simpler route involving the form attributes and ng-show statements instead of a custom directive. The custom directive route is likely DRY'er overall though. The form also incorporates a tag manager. The tag manager is essentially the functionality of a multi-select checkbox input with the smaller profile of a select input. The most difficult part was looking up how to pass the form from the parent scope to the tag manager directive.

I'm pretty happy with this first iteration of it (considering my experience developing with Angular). The repository is here. Feel free to send a PR if you have any feedback!

back