2

基本上在页面上有两个 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'"

4

1 回答 1

7

您正在寻找过滤器过滤器...

<tr ng-repeat="event in events | filter:{ type: 'First'}"/>
于 2013-01-16T21:01:29.107 回答