https://blog.ninja-squad.com/2018/05/04/what-is-new-angular-6/
Basically by defining our services this way they will be tree shaken. Meaning if a service isn't used it won't be included in the final bundle. To do that we must define our services like this:
@Injectable({
providedIn: 'root'
})
export class OcMeService{
}
And then remove the service definition in the relevant module. New services that are created will already be build this way so we'd just need to clean up the old usage.
Other pretty awesome benefits:
- services wont need to be registered in modules they'll "just work"
- non-mocked services won't need to be defined in tests they'll "just work"
https://blog.ninja-squad.com/2018/05/04/what-is-new-angular-6/
Basically by defining our services this way they will be tree shaken. Meaning if a service isn't used it won't be included in the final bundle. To do that we must define our services like this:
And then remove the service definition in the relevant module. New services that are created will already be build this way so we'd just need to clean up the old usage.
Other pretty awesome benefits: