Currently, I am using Angular to develop a large application and I have some common methods for controllers. As of now, this is how I am implementing it. However, is there a better way to approach this?
app.controller('baseController', function($scope, $controller, appFactory) {
var $scope.foo = function() {
// Perform certain actions
}
});
app.controller('childController', function($scope, $controller, appFactory) {
// Here I am extending or something similar to the base controller
$controller('baseController', {$scope: $scope});
var $scope.bar = function() {
// Perform multiple actions and then call foo
$scope.foo();
}
}):
I am following this approach because these methods require access to the $scope of my controller.