SITUATION:
I am making an app in AngularJs that assign permissions. In order to do this i have three nested ng-repeat.
First loop:
I would create a factory for category then move your get_sub_categories function into this new factory.