Showing posts with label Singleton Service. Show all posts
Showing posts with label Singleton Service. Show all posts

Saturday, August 15, 2020

Angular Singleton Services

A Singleton Service is one which has only one instance shared across the entire Angular App, it is a great way to share data across different components even if they don’t have any Hierarchal relationship. Services can be declared Singleton by setting the providedIn property of the @Injectable() to "root", when creating the service.

@Injectable({
  providedIn: 'root',
})