refactor angular code for minification + add some docs