Angularjs refactoring.