【发布时间】:2014-12-12 23:36:14
【问题描述】:
我在尝试在重复语句旁边使用 if 时遇到问题。
我在取数据,如下:
modules: Array[1]
0: Object
embed: "<iframe width="600" height="338" src="https://www.youtube.com/embed/UqdDAn4_iY0"
frameborder="0" allowfullscreen="" style="margin:0px auto;display:block;"></iframe>"
type: "embed"
1: Object
src: "https://m1.behance.net/rendition/modules/127899607/disp/072cebf2137c78359d66922ef9b96adb.jpg"
type: "image"
所以,如果模块有图像类型,我想获取图像。如果它具有嵌入类型,我想获取 iframe。我当前的视图代码是:
<div ng-repeat="project in project.modules" ng-if="project.type == 'image'">
<img src="{{ project.src }}" class="img-responsive img-centered" alt="{{ project.name }}"/>
</div>
如果我取出 ng-if,效果会很好。控制台输出如下错误:
Error: Multiple directives [ngRepeat, ngIf] asking for transclusion on: <!-- ngRepeat: project in project.modules -->
【问题讨论】:
标签: javascript angularjs if-statement