Javascript 在AngularJS中的HTML img src中使用字符串连接
我正在使用YouTube API v3从播放列表中提取视频。每个视频JSON对象都有一个videoId。我试图使用videoId在img元素中用Angular构建src属性 这就是我目前拥有的:Javascript 在AngularJS中的HTML img src中使用字符串连接,javascript,jquery,html,angularjs,youtube,Javascript,Jquery,Html,Angularjs,Youtube,我正在使用YouTube API v3从播放列表中提取视频。每个视频JSON对象都有一个videoId。我试图使用videoId在img元素中用Angular构建src属性 这就是我目前拥有的: <table id="playlistvideostable" class="table table-responsive table-striped"> <thead> <tr> <th>Name</
<table id="playlistvideostable" class="table table-responsive table-striped">
<thead>
<tr>
<th>Name</th>
<th>Thumbnail</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="video in playlistvideos">
<td>
{{video.snippet.title}}
</td>
<td>
<img src="http://img.youtube.com/vi/{{video.resourceId.videoId}}/hqdefault.jpg" alt="Video Thumbnail" class="img-responsive"/>
</td>
</tr>
</tbody>
</table>
名称
缩略图
{{video.snippet.title}
如何在img html元素的src属性中连接以下字符串
“+video.resourceId.videoId+”/hqdefault.jpg“使用ng src指令而不是图像元素的原始src属性,ng src指令将识别字符串插值并将其应用于dom 就你而言—
<img ng-src="http://img.youtube.com/vi/{{video.resourceId.videoId}}/hqdefault.jpg" alt="Video Thumbnail" class="img-responsive"/>
祝你好运。我认为ng src而不是src应该按照上面所示的方式进行操作?发生了什么?我的朋友,这应该有用。你做得很好