buonasera,
vorrei manipolare il DOM tramite angular.element la riga di codice che ho scritto però non fa ciò che vorrei,
chiedo a voi è un errore di angular.element usato male oppure è la variabile che richiamo che ha problemi?
pasto un pò di codice
file: index.html
file: takepic.htmlcodice:<html>.....<script> var gpsSuccess = function(position) { var latitude = position.coords.latitude; var longitude = position.coords.longitude; var gpstimestamp = position.timestamp; var image; }; function onSuccess(imageData) { gpsSuccess.image = document.getElementById('myImage'); gpsSuccess.image.src = "data:image/jpeg;base64," + imageData; angular.element("#img_photo").attr("src", gpsSuccess.image.src); navigator.geolocation.getCurrentPosition(gpsSuccess, gpsFail); }
codice:<div style="text-align:center;" ng-controller="TakeGPSData"> <img id="img_photo" src="" /> <br/> <button>Annulla</button> <button ng-click="myGPS.doClick(item, $event)">Invia</button> <br/> {{gpsSuccess.image.src}} </div> </ion-content> <script> angular.module("starter", []).controller("TakeGPSData", function($scope, $http) { $scope.myGPS = {}; $scope.myGPS.doClick = function(item, event) { var responsePromise = $http.post("127.0.0.1:5000/sendreport", angular.toJson(gpsSuccess)); responsePromise.success(function(data, status, headers, config) { $scope.myGPS.fromServer = data.title; /* this line must be change because we don't want title but gps image's coords */ }); responsePromise.error(function(data, status, headers, config) { alert("AJAX failed!"); }); } }); </script>
dopo che ho fatto la fotografia e l'ho "salvata temporaneamente" dovrebbe apparire nella pagina la fotografia che è stata scattata, ma non appare.
inoltre dove ho scritto: {{gpsSuccess.image.src}} speravo mi stampasse il valore della variabile in questione però non lo stampa e mi rimane scritto così come l'ho scritto ora
qualcuno può aiutarmi?

Rispondi quotando
