Cannot find name 'DatePicker'. in ionic2


#1

I already installed ionic-native and
ionic plugin add cordova-plugin-datepicker
Then import the DatePicker plugin in code:
import {DatePicker} from ‘ionic-native’;

The error occur on below line.
constructor(public navCtrl: NavController, public navParams: NavParams, public DatePicker: DatePicker)

The error message is: Cannot find name ‘DatePicker’.


#2

Please import it in ap.module.ts as well and mention in it imports.


#3

I already did:
In app.module.ts
import {DatePicker} from ‘ionic-native’;

@NgModule({
declarations: [
MyApp,
HomePage,
Signup,
DatePicker
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage,
Signup,
DatePicker
]


#4

Well as per the documentation.

First run:
$ ionic plugin add --save cordova-plugin-datepicker
$ npm install --save @ionic-native/date-picker

Then you need to import from @ionic-native/date-picker like so:

import { DatePicker } from '@ionic-native/date-picker';

Also be sure you add the module to your app.module.ts


#5

When i installed this
npm install --save @ionic-native/date-picker

and run i get following error:
typescript: node_modules/@ionic-native/date-picker/index.d.ts, line: 1
Module ‘"/Users/Hassan/alstomWifi/node_modules/@ionic-native/core/index"’ has no exported member
’IonicNativePlugin’.

   L1:  import { IonicNativePlugin } from '@ionic-native/core';
   L2:  export interface DatePickerOptions {

#6

Concering the IonicNativePlugin error, it is related to this github issue.


#7

Thanks @kgaspar. It is working.