InterviewSolution
| 1. |
How Can You Access Mobile Phone Native Functionality In Ionic Applications, For Example The Camera? |
|
Answer» Ionic does not provide a camera API out of the box. However, since Ionic uses plugins architecture, and because it is BASED on Cordova, we can use Cordova plugins in our application. Ionic team provides a set of Cordova extensions with Angular wrappers, and they can be found at ngCordova. To use Cordova plugins, we need to install the plugin using Ionic command install <plugin name>. In some cases, we will additionally need to add the plugin’s Angular MODULE to your Angular application too. To use a mobile phone’s camera in the Ionic application, we can call the camera API by using cordova-plugin-camera that is hosted on GitHub. This plugin defines a global navigator.camera object, which provides an API for taking pictures and for choosing images from the SYSTEM’s image library. Ionic does not provide a camera API out of the box. However, since Ionic uses plugins architecture, and because it is based on Cordova, we can use Cordova plugins in our application. Ionic team provides a set of Cordova extensions with Angular wrappers, and they can be found at ngCordova. To use Cordova plugins, we need to install the plugin using Ionic command install <plugin name>. In some cases, we will additionally need to add the plugin’s Angular module to your Angular application too. To use a mobile phone’s camera in the Ionic application, we can call the camera API by using cordova-plugin-camera that is hosted on GitHub. This plugin defines a global navigator.camera object, which provides an API for taking pictures and for choosing images from the system’s image library. |
|