Angular refactoring by directive hierarchy