I'm creating an angular factory that encapsulates and injectable type that can be new-ed up as such:
(function() {
angular
.module('app')
.factory('PaymentStream', [
function() {
function PaymentStream(){
this._endingBalance = null;
}
PaymentStream.prototype.serialize = function() {
// method body here
};
return PaymentStream;
}]);
})();
When I create a PaymentStream via new PaymentStream() only the constructor seems to have been called. If I don't use prototype and just define the methods inside the constructor it works but then I'm redefining the functions with each instance.
Any idea why those prototypes are not being set?
Edit
Here is how it is being used in the outside.
function addStreamFunctions(stream) {
angular.merge(stream, new PaymentStream());
}