我想要这个数组:
// Departments is your data source
//Find the department
var department= Departments.FirstOrDefault(d=>d.DepartmentID=="D2");
if(department!=null)
{
//Get all the orders from that Store
var orders= department.Store.Departments.SelectMany(d=>d.Orders);
}
我希望使用angular:
在html中显示数据和索引var data = [1, 2, 3, 4, 5];
,输出为
<div ng-repeat="data in data">
<p> index of {{ data }}: {{ something here }} </p>
</div>
可能的?
答案 0 :(得分:4)
使用$index
重复元素的迭代器偏移量(0..length-1)
<div ng-repeat="data in data">
<p> index of {{ data }}: {{ $index }} </p>
</div>