Is there a way to bind @Injectable () in Angular4

I am creating an Ionic 3 app (uses Angular 4). I've created a LocationProvider that will allow me to extract location services from the actual page logic so that it can be reused.

My LocationProvider uses @ ionic-native / geolocation (geolocation provider).

When I insert my LocationProvider into the page via @NgModule({ providers: [LocationProvider] })

, I get an error stating that no geolocation provider was found. Is there a way to enable the geolocation provider when using the LocationProvider? Or should I always have providers:[LocationProvider, Geolocation]

?

I'm guessing this is Ionic independent (but Angular 4), is there a way to get around the vendor list in NgModule

?

+3


source to share


1 answer


providers

accepts both single providers and provider arrays.

it could be



export const LOCATION_PROVIDERS = [LocationProvider, Geolocation];
...
providers: [LOCATION_PROVIDERS]
...

      

Providers can also be wrapped in their own module and imported.

+1


source







All Articles