Last active
December 26, 2015 20:19
-
-
Save pose/7207762 to your computer and use it in GitHub Desktop.
Pseudo-inheritance in JS
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
angular.module('otherModule', ['myModule']) | |
.factory('consumer', function (myClass) { | |
var instance1 = myClass(), | |
instance2 = myClass(), | |
instance3 = myClass(); | |
}}) | |
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
angular.module('otherModule', ['myModule']) | |
.factory('consumer', function (mySingleton) { | |
var instance = mySingleton; | |
}}) | |
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
angular.module('myModule', []) | |
.factory('myClass', function () { | |
function myClass() { | |
var d = {}; | |
d.myMethod = function (x) { | |
return x + 5; | |
} | |
return d; | |
} | |
return myClass; | |
}); |
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
angular.module('myModule', []) | |
.factory('mySingleton', function () { | |
function myClass() { | |
var d = {}; | |
d.myMethod = function (x) { | |
return x + 5; | |
} | |
return d; | |
} | |
return myClass(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment