Cordova-Examples icon indicating copy to clipboard operation
Cordova-Examples copied to clipboard

Is there anyway to call the var resultDiv in ng-model?

Open Manoj27893 opened this issue 8 years ago • 6 comments
trafficstars

var resultDiv;

document.addEventListener("deviceready", init, false); function init() { document.querySelector("#startScan").addEventListener("touchend", startScan, false); resultDiv = document.querySelector("[ng-model='user.result']"); } function startScan() {

    cordova.plugins.barcodeScanner.scan(
        function (result) {
            //var s = result.text;
            var s = result.text;
            resultDiv.innerHTML = s;
        }, 
        function (error) {
            alert("Scanning failed: " + error);
        }
    );

}

Manoj27893 avatar Dec 16 '16 15:12 Manoj27893

Can you please tell me which demo you are talking about?

cfjedimaster avatar Dec 16 '16 15:12 cfjedimaster

Hi cfjedimaster, For barcode scanner example.. I want the result.text to be filled automatically in input so that i can submit it to my DB using mysql.

Thanks in advance ....

Manoj27893 avatar Dec 17 '16 06:12 Manoj27893

If Angular 1, just use a $scope variable. You would store 's' to it.

cfjedimaster avatar Dec 17 '16 15:12 cfjedimaster

That Means i have to write $scope.s = result.text; so that it will store the result.text value in s and i call the value of variable 's' in my form like:

It will filled in the input field automatically ?

Manoj27893 avatar Dec 17 '16 15:12 Manoj27893

Um, not quite sure I get your reply, but sure. :) You are now asking a basic AngularJS question - nothing specific to my code or Cordova.

cfjedimaster avatar Dec 19 '16 12:12 cfjedimaster

yes sir... I figured it out .... Thanks for your help :)

Manoj27893 avatar Dec 20 '16 10:12 Manoj27893