I am using ngFileUpload
to upload the image from drive and I need to bind that selected image into anchor tag. Here is my code:
<div ng-repeat="mul in mulImage">
<input type="file" class="filestyle form-control" data-size="lg" name="upload_{{$index}}" id="bannerimage_{{$index}}" ng-model="mul.image" ngf-pattern="'image/*'" accept="image/*" ngf-max-size="2MB" ngf-select="onFileSelect1($index);">
<a href="mul.image" data-spzoom data-spzoom-width="400" data-spzoom-height="400"><img ngf-thumbnail="mul.image" name="pro" id="imgBig" border="0" style="width:32px; height:32px; border:#808080 1px solid;" ng-if="mul.image !=null"></a>
</div>
Here when user is selecting any image from drive it's displaying using img ngf-thumbnail
but here I need same time that particular image URL should set in a href=""
. I have done something but it's not working as expected.
In html:
<div ng-repeat="mul in mulImage">
<input type="file" ng-model="mul.image" ng-change="getFileUrl(mul)">
<a href="mulImage[mulImage.indexOf(mul)].imageLink"></a>
</div>
In controller:
$scope.getFileUrl = function(image) {
var reader = new FileReader();
reader.readAsDataURL(image.image);
reader.onload = function () {
$scope.mulImage[mulImage.indexOf(image)].imageLink = reader.result;
};
}
您应该使用<a ng-href="mul.image"
而不是<a href="mul.image"
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.