Reorganize angular javascript structure