2014-12-04 25 views
0

我想要绑定到一个数组内的数组。然后我想使用ng-repeat在空白div容器中显示第二个数组的所有“名称”项。我的代码如下所示:用一个Ng-Repeat绑定到一个阵列内的阵列

$scope.workflows = [{ 
    Id: 1, 
    Name: "Name of first workflow(*don't want to repeat*)", 
    Description: "Education focus area requests", 
    Steps: [{ 
     Id: 1, 
     Name: "**Name I DO Want to Repeat**", 
     Description: "The concept paper listed below", 
     Action: "Get Approval From", 
     Obj: "Program Officer - Group", 
     AdditionalInfo: "n/a", 
    }, { 
     Id: 2, 
     Name: "**Name I DO Want to Repeat**", 
     Description: "Describe", 
     Action: "Do things", 
     Obj: "n/a", 
     AdditionalInfo: "n/a", 
    }, { 
     Id: 3, 
     Name: "**Name I DO Want to Repeat**", 
     Description: "Describe", 
     Action: "Do things", 
     Obj: "n/a", 
     AdditionalInfo: "Additional", 
    }, 
]}, 

这是HTML

<div class="commentContainer" style="width: 100%"> 
    <div class="textBlue" ng-repeat="workflow in selectedWorkflow track by $index" style="width: 100%; margin-top: 7px; margin-bottom: 5px"> 
     {{selectedWorkflow.Name}} 
    </div> 
</div> 

(这是我选择的工作流程来源于)

$scope.selectedWorkflow = {}; 
$scope.selectWF = function(wf) { 
     $scope.selectedWorkflow = wf; 
     console.log(wf); 
     $scope.goAway = 1; 
    } 

,我应该在我的NG-重复改变什么码并在我的绑定,来到我的第二个数组中的“名称”对象重复,而不是第一个数组中的“名称”对象?

回答

0

我想你打算打印一个selectedWorkflow的步骤,对吗?因此,迭代(即ng-repeat)在selectedWorkflow.Steps

<div ng-repeat="step in selectedWorkflow.Steps track by $index"> 
    {{step.Name}} 
</div> 
+0

非常感谢!我已经尝试了一切,但那和它工作!我在这个新的。谢谢! – Bradston07 2014-12-04 16:41:48

0
<div class="commentContainer" style="width: 100%"> 
    <div class="textBlue" ng-repeat="step in selectedWorkflow.Steps track by $index" 
      style="width: 100%; margin-top: 7px; margin-bottom: 5px"> 
      {{step.Name}} 
    </div> 
</div> 

我假设你只是想的选定工作流程的步骤列表。

如果是这种情况,那么您需要在所选工作流程的步骤中进行重复。在这种情况下,在上面的模板中,每个“step”将代表workflow.Steps数组中的一个对象。