cfjedimaster / Cordova-Examples

A collection of Cordova/Ionic/etc demos.
980 stars 1.07k forks source link

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

Open Manoj27893 opened 7 years ago

Manoj27893 commented 7 years ago

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);
        }
    );

}
cfjedimaster commented 7 years ago

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

Manoj27893 commented 7 years ago

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 ....

cfjedimaster commented 7 years ago

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

Manoj27893 commented 7 years ago

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 ?

cfjedimaster commented 7 years ago

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.

Manoj27893 commented 7 years ago

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