in Angular by
Q:
What is a singleton pattern and where we can find it in Angular?

▼ Show 1 Answer

0 votes
by

Singleton pattern in Angular is a great pattern which restricts a class from being used more than once. Singleton pattern in Angular is majorly implemented on dependency injection and in the services. Thus, if you use ‘new Object()’ without making it a singleton, then two different memory locations will be allocated for the same object. Whereas, if the object is declared as a singleton, in case it already exists in the memory then simply it will be reused.

Angular JS
Learn More with Madanswer
...