I have a state called homeInside and it's controller and template in my angularjs app (I'm using routing). There is a lot of elements, also a button with ng-click linked to doSomething. I have another state called homeOutside. This is completely is similar to first one, but doSomething do another task.
I don't want to duplicate anything. How can I do this with one single controller and template? Is it the reason that Angular2 components comes into play for such scenarios (with it's constructor)?
Any idea would highly appreciated.
Edit:
In the first state:
$scope.doSomething = function() {
AuthService.logout();
}
In the second one:
$scope.doSomething = function() {
$state.go('dashboard');
}
All of the other parts are exactly the same.