I've encountered a challenge while setting up nested views in AngularJS. Utilizing the ui-router library has been beneficial, but I'm facing issues with separate controllers for each view without proper inheritance between them. This results in having to utilize $scope.$parent to modify variables in a parent controller from a child controller, which can get cumbersome when dealing with multiple levels of inheritance. Forgetting to use $parent in a child controller may lead to creating unintended instances of variables, potentially causing difficult-to-troubleshoot bugs.
An ideal solution would involve implementing prototype inheritance, aligning well with classes in Typescript or Coffeescript. One approach could be eliminating parent controllers entirely and utilizing child controllers inheriting common functionality from prototypes (super classes). Placing the controller on $rootScope would allow parent views to access it easily.
Are there any drawbacks to this approach or better alternatives? Is sticking with $parent and relying on Angular for "inheritance" a more efficient choice?
Any insights would be greatly appreciated.