With Angular 6, below is the preferred way to create singleton services:
import { Injectable } from \'@angular/core\';
@Injectable({
providedIn: \'root\',
})
provideIn: root this could be useful in those scenarios where you have multi-application projects. In such kind of scenarios, you have an angular workspace with multiple projects inside it.
And, you would never want your project to have some kind of dependencies on the workspace's core module as it won't allow you to run your project independently.
In such a case, you keep your services in the library and use providedIn: 'root' for making them singleton.