fus*_*sio 6 variables attributes angularjs angularjs-ng-repeat
我有以下内容:
div.container
script(src='/js/bootstrap/holder.js')
p.text-info(ng-pluralize,
count="devices.length",
when="{ '0': 'There are no fragments.', 'one': 'There is 1 fragment.', 'other': 'There are {} fragments.'}")
ul.unstyled(ng-repeat='fragment in devices')
ul.thumbnails
li.span
div.thumbnail
img(src="holder.js/{{fragment.dimension.width}}x{{fragment.dimension.height}}")
div.caption
h3 {{fragment.name}}
p {{fragment.dimension}}
ul.unstyled(ng-repeat='component in fragment.components')
li {{ component.name }}
Run Code Online (Sandbox Code Playgroud)
问题在于src="holder.js/{{fragment.dimension.width}}x{{fragment.dimension.height}}",即使查看生成的html我看到正确的src(src="holder.js/300x200")它也没有显示图像.我猜这不是如何在属性中使用角度变量的.
我怎样才能使它工作?
编辑:它似乎没有执行holder.js..这里是源:在第一次调用我使用角{{hash}}在第二个我手动放holder.js/300x200
<div class="thumbnail">
<img src="holder.js/1678x638">
<img src="data:image/png;base64,iVBORw0KG...ElFTkSuQmCC" data-src="holder.js/300x200" alt="300x200" style="width: 300px; height: 200px;">
</div>
Run Code Online (Sandbox Code Playgroud)
该文件解释说,很清楚:
像
{{hash}}在src属性中一样使用Angular标记不能正常工作:浏览器将使用文字文本从URL中获取,{{hash}}直到Angular替换其中的表达式{{hash}}.ngSrc指令解决了这个问题.
所以你必须使用:
<img ng-src="holder.js/{{fragment.dimension.width}}x{{fragment.dimension.height}}" />
Run Code Online (Sandbox Code Playgroud)