F
F
faragly2015-01-04 09:46:41
Angular
faragly, 2015-01-04 09:46:41

How to extend controller in AngularJS?

Hello dear developers! There is a need for different files to use the same angularjs controller. How to create a second controller so that the functions of the first one are also available?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Villarou, 2015-01-04
@faragly

Look one and two . With examples so everything should be clear

M
Mikhail Osher, 2015-01-04
@miraage

I like it this way.

ChildCtrl.$inject = ['$scope', '$injector', 'BaseCtrl'];
function ChildCtrl($scope, $injector, BaseCtrl) {
  $injector.invoke(BaseCtrl, this, {$scope: $scope});
  
  // Other controller stuff
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question