I am currently interested in developing an object that can be instantiated at any time and still make use of angular services:
Consider the example object below:
var myObject = function (variableOne, variableTwo) {
this.variableOne = variableOne;
this.variableTwo = variableTwo
};
myObject.prototype.useAngularService = function () {
return $sessionStorage.user;
};
Obviously, this object
cannot directly utilize $sessionStorage
. My question is how could you create a similar object that has the ability to leverage angular services?
The main reason for opting for this approach instead of using a service or factory is because I require multiple instances of this object and not a singleton solution.