如何在 angularjs 中获取上传图片的缩略图

how to get the thumbnail image of an uploaded image in angularjs

我上传了一张图片并将其保存为 mongodb 中的缩略图,但是当我将其检索到应用程序时,缩略图没有显示。这是application.js

这是我的代码

    var mongoose = require('mongoose');
    var thumbnailPluginLib = require('mongoose-thumbnail');
    var thumbnailPlugin = thumbnailPluginLib.thumbnailPlugin;

    var Schema = mongoose.Schema;

        enter code here

    var ApplicationSchema = new Schema({
        appName: String,
        appTempPath:String,
        userId : String,
        status : String,
        templateId: String,
        themeColor : String,

    });
    ApplicationSchema.plugin(thumbnailPlugin, {
      name: "appIcon"


    });

    var Application = mongoose.model('Application', ApplicationSchema);

这是我的view.html

<a ui-sref="{{templateApp.target}}">
    <button class="panel panel-primary" title="App information">
    <img src="{{templateApp.image}}"></img>
        <div class="panel-heading">{{templateApp.title}}</div>
            <div class="panel-body">
              <div ng-show='!!templateApp.info'>


                  <hr/><span class="product__price highlight">
                {{templateApp.info}}</span>
              </div>
        </div>
  </button>
</a>

我上传的图片可能很大,但是通过mongoose-thumbnail就变成了一个小图标。我需要一个小图标才能出现在我的应用程序框中。该图像未出现在我的 appBox 中。请给我这个问题的答案。 url 与检查中一样从数据库进入视图。

尝试在您的 img 中使用 ng-src 而不仅仅是 src

来自文档:

Using Angular markup like {{hash}} in a src attribute doesn't work right: The browser will fetch from the URL with the literal text {{hash}} until Angular replaces the expression inside {{hash}}. The ngSrc directive solves this problem.

编辑: 看到图片来源(评论里),需要清空,只包含http://....