Installation
To add Ionic Native to your app, run following command to install the core package:
$ ionic cordova plugin add cordova-plugin-tts
$ npm install --save @ionic-native/text-to-speech
Note that Ionic Native core package is included by default with every Ionic app.
Usage
Install the Needed Plugins
Install the Ionic Native package for each plugin you want to add.
For example, if you want to install the Camera plugin, you will need to run the following command:
npm install @ionic-native/camera --save
Then install the plugin using Cordova or Ionic CLI.
For example:
ionic cordova plugin add cordova-plugin-camera
All package names are documented on the plugin’s documentation. It is recommended to follow the installation instructions on each plugin’s documentation, as some plugins require additional steps to fully install.
Add Plugins to Your App's Module
After installing a plugin’s package, add it to your app’s NgModule
.
... import { Camera } from '@ionic-native/camera'; ... @NgModule({ ... providers: [ ... Camera ... ] ... }) export class AppModule { }
在使用的页面中引入: import { Camera } from '@ionic-native/camera';
在官网介绍中使用里面的函数。