使用ng-file-upload

时间:2017-07-01 00:26:34

标签: angularjs ng-file-upload

我正在使用ng-file-upload上传图片。我想显示图像的缩略图。我正在使用角1.6。有人可以粘贴所选图像缩略图的工作代码吗?

2 个答案:

答案 0 :(得分:1)

ng-file-upload <div|span|... *ngf-thumbnail="file" // Generates a thumbnail version of the image file ngf-size="{width: 20, height: 20, quality: 0.9}" // the image will be resized to this size // if not specified will be resized to this element`s client width and height. ngf-as-background="boolean" // if true it will set the background image style instead of src attribute. > 开始,您可以使用自定义指令显示图像的缩略图预览:

<img class="your_class"
     ngf-thumbnail="path/to/file.jpg"
     ngf-size="{width:200, height:200, quality:1.0}"/>

以下是缩略图标签的示例

db.collection.aggregate([
  {$match: {name: "something"}},
  {$project: {html: {$substrCP: ["$html",0,50]}}}
])

答案 1 :(得分:0)

从5.1.0版开始,使用ngf-background指令。

<div class="your-thumbnail-class" ng-show="!!yourModel" ngf-background="yourModel"></div>