gpt4 book ai didi

javascript - ng-repeat 在 ng-repeat-start 中重复

转载 作者:行者123 更新时间:2023-11-30 15:46:38 26 4
gpt4 key购买 nike


我的数据:

$scope.members = [
{
projects: [...]
},
{
projects: [...]
}, ...
] // $scope.members.length == 15

我的代码:

<tr>
<th ng-repeat-start="member in members" ng-repeat="project in member.projects" ng-repeat-end ng-if="member.projects" >
{{project.name}}
</th >
</tr>

没有生成元素。我检查了 Chrome 开发人员工具中的元素,我在 <tr> 中找到了这些像这样标记评论:

<!-- ngRepeat: member in members -->

<!-- ngRepeat: member in members -->
<!-- end ngRepeat: member in members --> (x30)

我也试过这个:

<tr ng-repeat-start="member in members">
<th ng-repeat="project in member.projects" ng-repeat-end ng-if="member.projects" >
{{project.name}}
</th >
</tr>

但随后出现错误:Unterminated attribute, found 'ng-repeat-start' but no matching 'ng-repeat-end' found.

有人有想法吗?提前致谢。

最佳答案

更新的答案:

仅将“projects”数组放入一个新数组中,如下所示:

$scope.projectsOnly = [];//empty array
$scope.members.forEach(function(item){
$scope.projectsOnly.push(item.projects);
})

然后只循环到那个数组,像这样:

<tr>
<th ng-repeat="project in projectsOnly " >
{{project.name}}
</th >
</tr>

希望有所帮助,祝你好运。

关于javascript - ng-repeat 在 ng-repeat-start 中重复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39957983/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com