i just come across a sample code on Angular js Controllers inheritance from this url http://viralpatel.net/blogs/angularjs-controller-tutorial/
here is the code and i just do not understand one part.
<div ng-controller="BMWController">
My name is {{ name }} and I am a {{ type }}
<button ng-click="clickme()">Click Me</button>
</div>
<script>
function CarController($scope) {
$scope.name = 'Car';
$scope.type = 'Car';
$scope.clickme = function() {
alert('This is parent controller "CarController" calling');
}
}
function BMWController($scope, $injector) {
$injector.invoke(CarController, this, {$scope: $scope});
$scope.name = 'BMW';
}
</script>
1) i just do not understand this line of code $injector.invoke(CarController, this, {$scope: $scope});
2) which $scope is BMWController scope and which $scope is CarController scope ?
3) there is two scope {$scope: $scope} one in left and one in right which one is related with BMWController & CarController scope ?
4) why this keyword is used in invoke function ?
5) please help me to understand this line $injector.invoke(CarController, this, {$scope: $scope}); as much with easy explanation
thanks