我正在开发一款相机应用。有一个名为Take Photo
的按钮,用户可以在其中拍照,它将显示在该按钮的下方。
我需要的是什么。一旦我拍照n =和照片显示在拍照按钮下。我想将文字从拍照改为重拍照片。如果没有可用的图像,我需要显示拍摄照片文字。怎么做?
这是我的代码html
:
<button class="button button-energized" ng-click="getPhoto()">
Take Photos
</button>
<div class="spacer" style="height: 10px;" ></div>
<div style="padding-left: 20px; padding-top: 10px; padding-bottom: 30px;">
<img ng-src="{{lastPhoto}}" style="max-width: 70%;max-height: 70%;">
</div>
我的控制器代码:
$scope.getPhoto = function() {
Camera.getPicture().then(function(imageURI) {
console.log(imageURI);
$scope.lastPhoto = imageURI;
}, function(err) {
console.err(err);
}, {
quality: 75,
targetWidth: 320,
targetHeight: 320,
saveToPhotoAlbum: false
});
};
答案 0 :(得分:0)
您可以使用 ng-show 或 ng-if 来实现此目标
<button class="button button-energized" ng-click="getPhoto()"><span ng-if="!lastPhoto ">Take Photos</span><span ng-if="lastPhoto">Retake Photo</span></button>