How do I include ngCordova plugins in my ionic app?
I want to add Cordova plugins to my ionic app. But it doesn't seem to work.
I will go through the steps I did:
- Added cordova plugins to plugins folder.
- Included ng-cordova.min.js file in index.html before codova.js
- Introduced by ngCordova in app.js
- Injected the required plugin into my controller ($ cordovaBarcodeScanner in this case)
Can someone please help me with this?
+3
source to share
2 answers
You can add a plugin with
cordova plugin add https://github.com/wildabeast/BarcodeScanner.git
then use the plugin in your page like this
module.controller('BarcodeCtrl', function($scope, $cordovaBarcodeScanner) {
document.addEventListener("deviceready", function () {
$cordovaBarcodeScanner
.scan()
.then(function(barcodeData) {
// Success! Barcode data is here
}, function(error) {
// An error occurred
});
)};
This example and more information is available at http://ngcordova.com/docs/plugins/barcodeScanner/
See also https://blog.nraboy.com/2014/09/implement-barcode-scanner-using-ionic-framework/
0
source to share