I have two pages that are similar, but one has a little more functionality than the other. Is there a way I can "extend" a controller in AngularJS so that I don't duplicate the code, and have it inherit variables or functions instead?
Asked
Active
Viewed 54 times
0
-
2This might be a good reference http://stackoverflow.com/questions/16539999/whats-the-recommended-way-to-extend-angularjs-controllers – Lexi Apr 06 '16 at 18:33
-
You can achieve it by using prototypal inheritance, I would recommend on [this great article](http://blog.mgechev.com/2013/12/18/inheritance-services-controllers-in-angularjs/) by Minkov. – Pankaj Parkar Apr 06 '16 at 18:34
-
This is a great use case for using Factories and Services! – dYale Apr 06 '16 at 18:35
-
Don't do it, use Angular Services http://stackoverflow.com/questions/36083240/angularjs-controller-inheritance-vs-scope-inheritance/36084332#36084332 – Renan Ferreira Apr 06 '16 at 18:37