I'm using angular route and I have a situation, where two views basically manipulate the same data. Now, the data is provided via factory to both controllers. However, the functionalities are quite the same.
I won’t go into too many details, but creating a service or factory (which is commonly suggested in this situations) does not solve my issues, since the button clicks etc. are basically the same in both views. I'd still have to define the same button clicks twice, except the logic would be in the factory. The only difference between my two views is, that view2 has a few more functionalities than view1, otherwise it’s basically the same.
What I’d need now is some kind of controller inheritance. I found a couple of solutions, but I’m still searching for an optimal and correct solution. I used the angular.extend to clone the scope, but I’m not sure if this is the correct way.
Furthermore, what happens with $scope from view1 when it gets cloned to $scope in view2? Does it get overridden?
Here’s a simple example: http://jsbin.com/fiqeha/1/edit?html,js,output