We are only in our first project with angular2. I have a question about providing a service.
As I know, there are two ways to declare a provider with providers:[MyService]in your application. You can declare it globally in a tag @NgModuleor locally in a tag @Component.
As far as I know, the only difference between the two methods is the scope of the provision. When an application is widely distributed, only one component. From this, I would conclude that I should prefer to provide the service mainly (depending on the use of the service) locally in my particular component, in order to reduce the scope.
Is this correct, or are there any other differences between the two methods of declaration that I donβt know about?
source
share