I am attempting to add the Geolocation Ionic native plugin to my Ionic 2.0 application.
As per the instructions here, I have imported the geolocation plugin and I am attempting to add it to the ‘providers’ array on my AppModule decorator, but I am getting a syntax error:
import { Geolocation } from '@ionic-native/geolocation';
...
@NgModule({
declarations: [
MyApp,
BasketPage,
AccountPage,
AccountCreationPage,
CategoriesPage,
TabsPage,
LandingPage,
CategoryPage,
ProductPage
],
imports: [
IonicModule.forRoot(MyApp),
HttpModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
BasketPage,
AccountPage,
AccountCreationPage,
CategoriesPage,
TabsPage,
LandingPage,
CategoryPage,
ProductPage
],
providers: [
Geolocation,
{ provide: ErrorHandler, useClass: IonicErrorHandler }
]
})
export class AppModule {}
The providers array seems to only accept an object with the ‘provide’ and ‘useClass’ properties, so adding the Geolocation object didn’t work.
Also, if you check the Ionic documentation, the providers array looks different to mine? Why is that? When I checked the Ionic documentation, there are only two versions - v1 and ‘latest’. What about Ionic 2? I’m so confused.
What am I doing wrong here?