I have angular JS with 5 controllers and I want to all of the children inherit all functions of parent (datetimepicker, autorefresh etc.. that is predefined in parent controller) I tried with rootscope but didn't get solution
1 Answer
you can take common functionality into service/factory an use it in controllers
var app = angular.module('angular', []);
app.factory("common",function(){
return {};
})
app.controller('ChildCtrl', function($scope, $controller,common) {
});
or you can inherit from a controller like this
var app = angular.module('angular', []);
app.controller('ParentCtrl ', function($scope) {
ctrl to act as parent
});
app.controller('ChildCtrl', function($scope, $controller) {
$controller('ParentCtrl', {$scope: $scope});
});