I find myself often writing one service that wrap rest api (ApiService), then another service that wrap some business logic around it (ActionDispatcher), and then I need it in various controllers.
So ControllerA have:
...
$scope.funA = () => { ActionDispatcher.funA() };
$scope.funB = () => { ActionDispatcher.funB() };
$scope.funC = () => { this->funC_reimplemented() };
...
While ControllerB have:
...
$scope.funA = () => { ActionDispatcher.funA() };
$scope.funB = () => { this.funB_reimplemented() };
$scope.funC = () => { ActionDispatcher.funC() };
...
Is there Angular Way for something like?
function ControllerA(...) {
functionsFrom(ActionDispatcher);
...
$scope.funC = () => { this->funC_reimplemented() };
...
functionsFrom desired behavior:
- Only copy functions (I want my
ControllerAandControllerBto just delegate responsibilities toActionDispatcher) - Attach those new functions to
$scope - (Optionally) Attach those new functions to provided object (so
ControllerA As vmstill works)