Created
August 19, 2014 07:27
-
-
Save redgeoff/04c67d91a37e50f99ba8 to your computer and use it in GitHub Desktop.
A Pen by Geoff Cox.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html ng-app="app"><head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.18/angular.min.js"></script> | |
</head> | |
<body> | |
<script> | |
angular.module('app', []) | |
.factory('MySuperClass', function () { | |
var MySuperClass = function (x) { | |
this.x = x; | |
} | |
MySuperClass.prototype.foo = function () { | |
console.log('foo ' + this.x); | |
}; | |
return MySuperClass; | |
}) | |
.factory('MySubClass', function(MySuperClass) { | |
var MySubClass = function () { | |
MySuperClass.apply(this, arguments); | |
} | |
MySubClass.prototype = new MySuperClass(); | |
MySubClass.prototype.bar = function () { | |
console.log('bar'); | |
}; | |
return MySubClass; | |
}) | |
.controller('Ctrl', function (MySubClass) { | |
var sub = new MySubClass(7); | |
sub.foo(); | |
sub.bar(); | |
}); | |
</script> | |
<div ng-controller="Ctrl"> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment