【发布时间】:2016-01-21 01:00:25
【问题描述】:
我有一个显示基本客户信息(姓名和电子邮件)的视图,其中有客户详细信息表。
我尝试在 tbody 部分编写 ng-repeat,但子表没有获取数据并且它只打印一次。
我也尝试使用ng-repeat-start ng-repeat-end,但我收到错误提示找不到匹配的ng-repeat-end
错误:[$compile:uterdir] 未终止的属性,找到 'ng-repeat-start' 但没有找到匹配的 'ng-repeat-end'。
我的代码:
<table class="customer">
<thead>
<tr>
<th class="first">Customer Name <span class="sortable"></span></th>
<th class="opp-detail">Email</th>
</tr>
</thead>
<tbody ng-repeat="customer in customerList">
<tr>
<td>{{customer.Name}}</td>
<td class="opp-detail">{{customer.EMail}}</td>
<table class="customer-details collapsed" >
<thead>
<tr>
<th class="opp-detail">Name</th>
<th class="opp-detail">Address</th>
<th class="opp-detail">City</th>
<th class="opp-detail">Zip Code</th>
<th class="opp-detail">Contact</th>
<th class="opp-detail">Email</th>
<th class="opp-detail">Phone</th>
</tr>
</thead>
<tbody>
<tr>
<td class="opp-detail">{{customer.Name}}</td>
<td class="opp-detail">{{customer.Address}}</td>
<td class="opp-detail">{{customer.City}}</td>
<td class="opp-detail">{{customer.PostCode}}</td>
<td class="opp-detail">{{customer.Contact}}</td>
<td class="opp-detail">{{customer.EMail}}</td>
<td class="opp-detail">{{customer.PhoneNo}}</td>
</tr>
</tbody>
</table>
</tr>
</tbody>
</table>
任何想法应该如何解决?
测试数据:
[{ _id: 569fa2ab011d2ddc3065b802,
Name: 'Gicom',
SearchName: 'GICOM',
Address: 'some address',
Address2: '',
City: '',
Contact: '',
PhoneNo: '123456',
FaxNo: '',
PostCode: '',
Country: '',
EMail: 'mail@test.com',
MonitoringSource: 'US',
__v: 0 },
{ _id: 569fa2ab011d2ddc3065b803,
Name: 'Mitsui',
SearchName: 'MITSUI',
Address: '',
Address2: '',
City: '',
Contact: '',
PhoneNo: '',
FaxNo: '',
PostCode: '',
Country: '',
EMail: '',
MonitoringSource: 'US',
__v: 0 },
{ _id: 569fa2ab011d2ddc3065b804,
Name: 'Icon',
SearchName: 'ICON',
Address: 'customer address',
Address2: '',
City: 'some city',
Contact: '',
PhoneNo: '789456',
FaxNo: '',
PostCode: '',
Country: '',
EMail: 'mymail@test.com',
MonitoringSource: 'US',
__v: 0 }]
【问题讨论】:
-
你的
customerList对象是什么样的? -
我认为您应该为此使用嵌套表。
-
1.从 tbody 中删除 ng-repeat 并将其放在 tr 上。 2. 检查数据库中有多少条记录。 3. 检查您是否在后端查询中使用“LIMIT 1”来获取记录。如果是,请将其删除。最后,分享
customerList对象。 -
我在帖子中添加了 customerList 对象数据
-
@AntiHeadshot 你能解释一下你的意思吗?
标签: javascript angularjs