将二进制图像从 db 显示为角度局部视图 [英] display binary image from db to angular partial view

查看:24
本文介绍了将二进制图像从 db 显示为角度局部视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图显示来自 web api 请求返回的 json 对象中的图像.我能够在我的角度部分中显示字符串、数字和日期/时间,但无法显示图像.这是我的 json 对象,它包含我的主题(模型)类的每个字段

<主题><身体>dsadfsaadsfds</身体><创建>2014-06-15T00:00:00</创建><Flagged>false</Flagged><Id>1022</Id><照片文件>iVBORw0KGgoAAAANSUhEUgAAB2wAAAOiCAIAAAAzNbBAAAABiWlDQ1BJQ0MgUHJvZmlsZQAAKBWtkT1LA0EQht+L0SgJGCRoCpEFRSzu5IxFTLTJB5iIRYgKane5nImQj7UHJvZmlsZQAAKBWtkT1LA0EQht+L0SgJGCRoCpEFRSzu5IxFTLTJB5iIRYgKane5nImQj7UHYGEAiWlDQ1BJQ0MgUHJvZmlsZQAAKBWtkT2(我想发布屏幕截图,但由于缺乏声誉而无法发布......)</照片文件><回复 i:nil="true"/><Title>csdaadsf</Title>

这是我的 Angular html 部分:

 <a data-ng-href="#/message/{{ i.id }}">{{ i.title }}</a>

<div class="date span2">{{ i.created |日期:中等"}}

<div class="contents span12">{{ i.body }}

<img ng-alt="" src="{{'data:image'+i.photofile}}"/>

`

因为我可以让其他属性工作,我的角度工厂和控制器应该工作.我在显示图像的角度局部视图中的语法有什么问题吗?谢谢

解决方案

I was trying to display image which is coming within the json object returning from an web api request. I'm able to display string, number and date/time in my angular partial but couldn't get the image displaying. here is my json object which contains each field of my topic (model) class

<Topic>
<Body>dsadfsaadsfds</Body>
<Created>2014-06-15T00:00:00</Created>
<Flagged>false</Flagged>
<Id>1022</Id>
<PhotoFile>
iVBORw0KGgoAAAANSUhEUgAAB2wAAAOiCAIAAAAzNbBAAAABiWlDQ1BJQ0MgUHJvZmlsZQAAKBWtkT1LA0EQht+L0SgJGCRoCpEFRSzu5IxFTLTJB5iIRYgKane5nImQj+NyIfoD7Gy0EG0U9S+INhaWYqGFIAjB3yAEAi..........
(I want to post screen shot but i can't due to lack of reputations.....)
</PhotoFile>
<Replies i:nil="true"/>
<Title>csdaadsf</Title>

and here is my angular html partial:

    <a data-ng-href="#/message/{{ i.id }}">{{ i.title }}</a>
  </div>
  <div class="date span2">
    {{ i.created | date:"medium" }}
  </div>
  <div class="contents span12">
    {{ i.body }}
  </div>
    <img  ng-alt="" src="{{'data:image'+i.photofile}}" />    </div>

`

Since i can get other attributes working, my angular factory and controller should be working. Are there anything wrong with my syntax in angular partial view for displaying images? Thanks

解决方案

这篇关于将二进制图像从 db 显示为角度局部视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆