AngularJS img ng-src绑定不起作用

时间:2018-10-26 09:09:27

标签: angularjs

我试图将img的ng-src与$ scope变量绑定,但是当变量更改时,它不会刷新图像。

HTML

<body ng-app="CameraApp" ng-controller="cameraController">
<br/><br/>
<div align="center">
    <img id="myImage" ng-src="{{ imageSrc }}" ng-click="TakePicture();"/><br/><br/>
    <input type="button" ng-click="TakePicture();" value="TAKE PICTURE" /><br/><br/>
    <input type="button" ng-disabled="{{ savePict }}" value="SAVE PICTURE"/>
</div>

JS

var app = angular.module('CameraApp', ['ngTouch']);

app.controller('cameraController', function ($scope) {

$scope.savePict = true;
$scope.imageSrc = '';


$scope.TakePicture = function () {
    navigator.camera.getPicture(onSuccess, onFail, {
        quality: 50,
        destinationType: Camera.DestinationType.FILE_URI
    });
}

function onSuccess(imageUri) {
    $scope.imageSrc = imageUri;
}

function onFail(message) {
    alert('Failed because: ' + message);
    document.getElementById("myImage").src = "";
    $scope.savePict = true;
  } 
});

1 个答案:

答案 0 :(得分:0)

以这种方式解决

SELECT 
   strftime('%W', [DatumEintrag], 'weekday 1') Woche, 
   SUM([FOO]), 
   Count (Distinct [DatumEintrag]) as Tage 
FROM MainData Where [BAR] LIKE 'BC%' 
Group By Woche
having Count (Distinct [DatumEintrag])>4