JS Inheritance 1.0rc3
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.0rc3.js"></script>
<html>
<head>
<body ng-app="myApp">
<div ng-controller="Parent">
<button type="button"ng-click="clickParent()">
clickParent
</button>
<div ng-controller="Child">
<button type="button"ng-click="clickChild()">
clickChild
</button>
</div>
<!-- Something here ... -->
</div>
</body>
</head>
</html>
JavaScript
var myApp = angular.module('myApp',[]);
function Parent($scope) {
$scope.name = 'Superhero';
$scope.clickParent = function() {
$scope.name = 'Clicked from base controller';
}
}
function Child($scope, $injector) {
debugger;
$injector.invoke(Parent, this, {$scope: $scope});
$scope.name = 'Superhero Child';
$scope.clickChild = function(){
$scope.clickParent();
}
}