Skip to content

Instantly share code, notes, and snippets.

@adamweeks
Created May 12, 2015
Embed
What would you like to do?
angular.module('scanner.controllers', [])
.controller('HomeController', function($scope, $rootScope, $cordovaBarcodeScanner, $ionicPlatform) {
var vm = this;
vm.scan = function(){
$ionicPlatform.ready(function() {
$cordovaBarcodeScanner
.scan()
.then(function(result) {
// Success! Barcode data is here
vm.scanResults = "We got a barcoden" +
"Result: " + result.text + "n" +
"Format: " + result.format + "n" +
"Cancelled: " + result.cancelled;
}, function(error) {
// An error occurred
vm.scanResults = 'Error: ' + error;
});
});
};
vm.scanResults = '';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment