I need to use an additional service in my component. It seems I should be able to do it like so
@Component({
selector: 'page-home',
templateUrl: 'home.html',
providers: [firstService, additionalService]
})
but it doesn't work.
I need to use an additional service in my component. It seems I should be able to do it like so
@Component({
selector: 'page-home',
templateUrl: 'home.html',
providers: [firstService, additionalService]
})
but it doesn't work.
Copyright © 2021 Jogjafile Inc.
Without more code, its hard to understand how you are trying to implement your services. Angular Components consume services through dependency injection in the constructor of the component class, like this:
An instance of the service will be created every time you register it as a provider. It is a better practice to provide services at a module level of the application, not in the component. Services are created as singletons and then injected wherever they are needed. More information about modules and service providers can be found here in the Angular docs.