页面上基本上有两个ng-repeats,共享一个Object。我想只在符合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重复。 on for type = First,one for type = Second
像ng-repeat="event in events.type = 'First'"
答案 0 :(得分:7)
您正在寻找the filter filter ...
<tr ng-repeat="event in events | filter:{ type: 'First'}"/>