我在尝试使用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"
Run Code Online (Sandbox Code Playgroud)
所以,如果模块有一种图像,我想得到图像.如果它有类型嵌入,我想得到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>
Run Code Online (Sandbox Code Playgroud)
如果我拿出ng-if,它效果很好.控制台输出以下错误:
Error: Multiple directives [ngRepeat, ngIf] asking for transclusion on: <!-- ngRepeat: project in project.modules -->
Run Code Online (Sandbox Code Playgroud) 我正在尝试基于if条件将DbParameter添加到DbParameter数组,如下面的代码:
DbParameter[] prms = new DbParameter[]
{
CreateDbParameter("prmA", prmA),
CreateDbParameter("prmB", prmB)
};
if(!validate)
{
// Add prmC
}
Run Code Online (Sandbox Code Playgroud)
我怎么能做到这一点?提前致谢!