AngularJS port of Dan Palmer's jquery.complexify.js