Angularjs and Normal Javascript functions don't work together? -
the following code without angular association able draw file onto canvas, when write same code on view angular spa, doesn't seem work. i'm new angular. combination not allowed? or doing else wrong? apologies if question elementary.
<div class ="container"> <div class="jumbotron"> <p> <h3>claim token here</h3> </p> <p> click picture of qr code: </p> <!-- <p> <input type="text" ng-model="tokenid"> </p> --> <p> <input type="file" capture="camera" accept="image/*" id="camsource" name="camsource"> </p> <p> <canvas id="qr-canvas" width="300" height="300" style="border:1px solid #d3d3d3;"></canvas> </p> <p> <button type="submit" class="btn btn-default" role="button" onclick="myfunction()">decode qrcode</button> </p> <p> <button type="submit" class="btn btn-default" role="button" ng-click="claimtoken()"> {{claimbuttontext}} </button> </p> <p> <button class="btn btn-default" role="button" ng-click="gotoprofile()"> profile </button> </p> <p><h6 id="qr-value"></h6></p> <p>{{claimtokenstatus}}</p> </div> </div> <script> window.onload = function() { var input = document.getelementbyid('camsource'); input.addeventlistener('change', handlefiles, false); } function handlefiles(e) { var canvas = document.getelementbyid('qr-canvas') var ctx = canvas.getcontext('2d'); var url = url.createobjecturl(e.target.files[0]); var img = new image(); img.src = url; img.onload = function() { ctx.drawimage(img, 0, 0, 300, 300); } } </script>
for angular work on in app, must use ngapp directive. that's makes application angular application. also, make js file control html, use ngcontroller directive. finally, name assigned ngapp directive , ngcontroller directive in html , js must same. hope solved problem.
Comments
Post a Comment