我在一个数组中有一个数组,我在ng-repeats和ng-ifs方面遇到了一些问题。我的数组看起来像这样:
data.stage = [];
task_obj = {};
data.stage.push({
workflow_stage: wf.getDisplayValue('name'),
task: []
});
task_obj.number = userTasks.getValue('number');
task_obj.parent = userTasks.getValue('parent');
task_obj.state = userTasks.getValue('state');
task_obj.url = userTasks.getDisplayValue('url');
task_obj.incompleteCounter = incompleteCounter;
task_obj.icon = icon;
task_obj.status = status;
task_obj.style = style;
task_obj.short_description = userTasks.getValue('short_description');
task_obj.bundle_name = bundle.getValue('bundle_name');
task_obj.workflow = bundle.getDisplayValue('workflow');
task_obj.workflow_stage = bundle.getDisplayValue('workflow_stage');
for(var a=0; a < data.stage.length; a++){
if(bundle.getDisplayValue('workflow_stage') == data.stage[a].workflow_stage) {
data.stage[a].task.push(task_obj);
}
}
}
如果我的ng-repeat看起来像ng-repeat="item in data.stage track by $index"
,我将如何访问short_description?会不会像{{item.task.short_description}}
?
同样,如果我想写一个ng-if,其中bundle_name是&#34; MyBundle&#34;,我该怎么写呢?我已经尝试了ng-if="item.task.bundle_name=='MyBundle'"
,但它显然不起作用。
任何人都可以指导我正确的语法吗?
答案 0 :(得分:0)
您还需要使用ng-repeat进行任务
<div ng-repeat=ng-repeat="item in data.stage track by $index">
<div ng-repeat=ng-repeat="task in item.task track by $index">
<div ng-if="task.bundle_name == 'MyBundle' ">
My bundle condition
</div>
<span>{{task.short_description}}</span>
</div>
</div>