Avatar ·

What is the purpose of providedIn in the Injectable decorator when creating services in Angular 6?

Hello everyone! I started learning Angular 6 and TypeScript, and when generating a service via CLI I noticed this thing: ```typescript @Injectable({ providedIn: 'root' }) export class MyService { constructor() { } } ``` Previously, in Angular 5, I just wrote `@Injectable()` without any parameters, and then registered the service in the module in the `providers` section. And now CLI generates this `providedIn: 'root'`. I'm a bit confused. Here's how I used to do it: ```typescript // my.service.ts @Injectable() export class MyService { } // app.module.ts @NgModule({ providers: [MyService] }) export class AppModule { } ``` And now the new approach: ```typescript // my.service.ts @Injectable({ providedIn: 'root' }) export class MyService { } ``` Questions: 1. What exactly does