mercredi 20 mai 2015

Why are angular services Singletons?

I am trying to understand singleton pattern.

I write a lot of code in angular and recently I wanted to refactor some of my code and move it to a common place which can be shared by different controllers.So I moved all common utils to my services.

Now the documentation over here says that angular services are singletons but I want to understand the reason behind having singleton pattern here ? Why not have multiple instances of the service object instead of passing references to controllers ?

Aucun commentaire:

Enregistrer un commentaire