This is going to be a brief tutorial. In this guide, we will learn how to create an Ionic/Angular application for Flashlight by making use of the Cordova Flashlight plugin.
We are going to develop a simple application for an ionic torch, which will allow the user to turn the flashlight on or off by clicking a single button.
Ionic CLI should be installed.
On your local development machine, you need to run the following NPM command to install the most recent version of the Ionic CLI:
Check the Ionic CLI version:
Create an "blank" application using Ionic/Angular
In order to get started with the first step, we need to create an entirely new application for the ionic angular torch.
To manifest your Ionic project, run the following line in your terminal or cmd.
Move to the project root:
Cordova Flashlight Plugin Installation CMD in Ionic/Angular
Installing the ionic native flashlight module and the Cordova flashlight plugin are the next steps to take.
Import Flashlight Module in AppModule
The next step is to make sure that the Flashlight package has been imported into the AppModule class, and then to register the plugin in the providers array.
Go to src/app folder in your application and add the code in app.module.ts file:
Create a Usage for the Flashlight in Ionic/Angular
We will be use Ionic's default home component in order to create the flashlight function and usage; to do so, add the following code to the home.page.ts file.
Insert the code that is provided below into the home.page.html file.
Final Step - Build Ionic/Angular
Since we are developing a Cordova application, it will be most beneficial to test the application in an emulator.
For ios you can use following command: