gpt4 book ai didi

javascript - 将图像插入数组

转载 作者:行者123 更新时间:2023-11-28 18:32:43 24 4
gpt4 key购买 nike

我想拍摄不同元素的照片或为一件元素拍摄多张照片,但我正在努力弄清楚如何将图像推送到数组中。

从第一行开始显示单个图像:

<img ng-show="imgURI !== undefined" ng-src="{{imgURI}}" style="text-align: center">

但是使用ng-repeat它不会显示一张图像。

我怀疑我的问题是:

  1. 我的 ng-repeat 有什么问题吗?
  2. 图像实际上是否正确存储在数组内?

HTML

 <button class="button button-full button-assertive" ng-click="takePhoto()">
Take Photo
</button>
<img ng-show="imgURI !== undefined" ng-src="{{imgURI}}" style="text-align: center">
<ion-item class="item item-assertive">Test array</ion-item>
<div ng-repeat="x in array">
<img ng-src="{{x.imgURI}}">
</div> center">

Javascript

  $scope.takePhoto = function () {
var options = {
quality: 75,
destinationType: Camera.DestinationType.DATA_URL,
sourceType: Camera.PictureSourceType.CAMERA,
allowEdit: true,
encodingType: Camera.EncodingType.JPEG,
targetWidth: 300,
targetHeight: 300,
popoverOptions: CameraPopoverOptions,
saveToPhotoAlbum: false
};

$scope.array = [];

$cordovaCamera.getPicture(options).then(function (imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
$scope.imgURI = array;
}, function (err) {
// An error occured. Show a message to the user
});
}

最佳答案

您正在将 imageUri 设置为数组的值。

$scope.imgURI = ar;

我想你想像这样对数组进行推送:

$scope.array.push($scope.imgURI);

关于javascript - 将图像插入数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37674782/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com