AngularJS Extend a controller

Viewed 3699

Im using angular to build a big app and i have some common methods for controllers actualy im doing this, but exist a best way to do it?

app.controller('baseController', function($scope, $controller, appFactory) {
    var $scope.foo = function() {
        // Do something
    }
});


app.controller('childController', function($scope, $controller, appFactory) {

    // Here i extend or something like, the base controller

    $controller('baseController', {$scope: $scope});

    var $scope.bar = function() {
        // Do a lot of things an then call foo
        $scope.foo();
    }
}):

i do it because this methods need to have de $scope of my controller.

2 Answers
Related