JS Inheritance 1.0rc3
http://angularjs.org/
by mhevery
HTML
<script src="http://code.angularjs.org/angular-1.0.0rc3.js"></script>
<div ng-controller="Child">
Hello, {{name}}!
<br/>
<button ng-click="clickChild()">Click Me to use base controller (Doesnt work yet)</button>
<br/>
</div>
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();
}
}
Child.prototype = Object.create(Parent.prototype);