There are two ways to make a service a singleton in Angular:
providedIn property of the @Injectable() to "root".AppModule or in a module that is only imported by the AppModuleimport { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class UserService {
}