基本上在页面上有两个 ng-repeats 共享一个对象。只有当它们与数据匹配时,我才想重复项目type
。
模拟对象
$scope.events = [
{
date: "1/16/13",
time: "11:30",
type: "First",
restaurant: "Quiznos",
location: "Echo",
cuisine: "American",
link: "http://google.com/event?id=239292"
},
{
date: "1/16/13",
time: "1:30",
type: "Second",
restaurant: "Snarfs",
location: "5th Floor",
cuisine: "American",
link: "http://google.com"
}
];
标记
<tr ng-repeat="event in events.type " onClick="window.open('{{event.link}}','_blank');">
<td>{{event.time}}</td>
<td>{{event.restaurant}}</td>
<td>{{event.location}}</td>
<td>{{event.cuisine}}</td>
</tr>
所以我想要两个 ng-repeats。on 用于 type = First,一个用于 type = Second
就像是ng-repeat="event in events.type = 'First'"