我在嘗試使用if和重複語句時遇到了問題。AngularJS if語句與ng-repeat
我取數據,具體如下:
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 -->
謝謝你,這是做的伎倆! :) – 2014-10-17 12:13:57
這可能應該是根據你的問題選擇的答案。 – user1012500 2015-10-15 10:19:43