Angular: factory vs module template

Is there a good reason to use factory:

app.factory("Items", function() {
...
} );

instead of the IIFE module template:

var Items = (function() {
...
}());
  • no need to enter it into controllers, etc., it is always available
  • I can see it in the console, and I can not do it with the factory (or am I wrong?)

I am sure that I will find a few more reasons, so what are the advantages in favor of the factory? Thanks

+4
source share

Source: https://habr.com/ru/post/1616103/


All Articles