Hi All,
I have following sceniro in my current application
- i wrote Barcode scanner code in Factory Method
app.factory("getBarcode",function($q)
{
var dataService={};
dataService.codevalue;
dataService.scanCodeService=function(){
var deferred=$q.defer();
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
scanner.scan(
function(result) {
// alert("Scanned Code: " + result.text + ". Format: " +
result.format + ". Cancelled: " + result.cancelled);
deferred.resolve(result.text);
dataService.codevalue=result.text;
}, function(error) {
//alert("Scan failed: " + error);
deferred.reject(error.text);
});
return deferred.promise;
}
return dataService;
}
);
This will return me the Scanned Text.
- In Controller i wrote following thing
app.controller('addMeterController',['$scope', '$ionicActionSheet',
'$cordovaCamera','getBarcode',
function($scope, $ionicActionSheet, $cordovaCamera,getBarcode)
{
$scope.barcode=function(){
getBarcode.scanCodeService()
.then(function(data)
{
console.log('Data: -------------------------- >'+data);
$scope.meterno=data;
console.log('meterno : -------------------------- >'+$scope.meterno);
},function(data)
{
alert('error');
}
)
};
}]);
- My Html Contain Following part
<div class="row">
<div class="col-75"><input type="number" placeholder="Enter an existing
Meter Number" ng-model="meterno" ng-bind={{meterno}} value={{meterno}}
name="txtmeterno" ngMinlength="0"
ngMaxlength="10" required ng-pattern="/^(\d)+$/"></div>
<div class="col-25"><button class="button button-dark"
ng-click="barcode()">Scan</button></div>
</div>
I am refering meterno from controller. Barcode scaning functionality is
working fine on clicking of scan button . It print the console log. I want
to bind whatever value come from Barcode function to Text Field. First it
came to text field but after that it will not come. How can i bind my
scanned result text to text field.
Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.