问题
I am using ionic 3, I want to call a number and for that I have added ionic native plugin for call-number:
ionic cordova plugin add call-number
npm install --save @ionic-native/call-number
But it's throwing an error:
ERROR Error: Uncaught (in promise): Error: No provider for CallNumber!
回答1:
You also need to add CallNumber in the providers array of your AppModule (located in the app.module.ts file):
// ...
import { CallNumber } from '@ionic-native/call-number';
@NgModule({
declarations: [..],
imports: [...],
bootstrap: [IonicApp],
entryComponents: [...],
providers: [
CallNumber, // <--- Here! :)
...
...
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
回答2:
Add as a provider inside app.module.ts
providers: [
CallNumber,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
回答3:
add below code in your page.ts file
@Component({
selector: '',
templateUrl : '',
providers : [CallNumber]
来源:https://stackoverflow.com/questions/47484486/no-provider-for-callnumber-in-ionic-3