javascript AngularJS 使用两种方式数据绑定将 img 元素标签中的图像显示为源?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19732634/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AngularJS use two way data binding to display image in img element tag as source?
提问by Wes
I am making a http request that returns a url to an image. I would like to display the image in my html page. Is there a way to do this? I idea of what I want to do is (this doesn't work but..) img src={{result.imageurl}}
我正在发出一个 http 请求,该请求返回一个图像的 url。我想在我的 html 页面中显示图像。有没有办法做到这一点?我知道我想要做的是(这不起作用但是..) img src={{result.imageurl}}
回答by NicolasMoise
Yes, you have to use ng-src="{{result.imageurl}}"
是的,你必须使用 ng-src="{{result.imageurl}}"