我必须按顺序(连续数字)为ng-repeat和我使用$index
生成数字,但这又是从1到第二ng-repeat
的序列。
我尝试在范围内获取变量,然后在视图中递增,但这也无法解决。
代码:
<body ng-controller="MainCtrl">
<ul ng-repeat="detail in details">
<li><span>{{$index + 1}}</span><span> {{detail.name}}</span>
</li>
</ul>
<ul ng-repeat="detailed in details.name">
<li><span>{{$index + 1}}</span><span>{{detailed.prof}}</span></li>
</ul>
</body>
控制器:
app.controller('MainCtrl', function($scope) {
$scope.details = [
{ "name": "Employees" },
{ "name": "Support" }
];
$scope.details.name = [
{ "prof": "enginerr" },
{ "prof": "doctor" }
];
});
这里的吸虫工程师编号应为3,医生编号应为4。
任何帮助都将不胜感激。
答案 0 :(得分:4)
将ng-repeat
添加到第二个 <body ng-controller="MainCtrl">
<ul ng-repeat="detail in details">
<li><span>{{$index + 1}}</span><span> {{detail.name}}</span>
</li>
</ul>
<ul ng-repeat="detailed in details.name">
<li><span>{{details.length + $index + 1}}</span><span>{{detailed.prof}}</span></li>
</ul>
#include <stdio.h>
int a=1;
int b=5;
void fact(a,b) {
if(b == 1) {
return;
} else {
a = a * b;
b = b - 1;
fact(a, b);
}
}
int main() {
fact(a, b);
printf("%d", a);
}