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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -