javascript - Returning a new function instead of an object in factory -
is there drawback instead of returning object?
.factory('box', function(){ var box = (function(){ var privatevar; return { watch: { song: undefined, artist: undefined, id: undefined }, update: function() { } } }); return new box; })
the reason want way function can function prototype , use this.
no there isnt draw back, can use , take advantage of this
in returning function
.factory('example', ['$http', function($http) { return function(a, b) { this.a = a; this.b = b; }; }]);
and can make object outside also
var 1 = new example('a', 'b');
Comments
Post a Comment