gpt4 book ai didi

angularjs - Angular .js : ng-repeat based on item in object

转载 作者:行者123 更新时间:2023-12-01 00:39:41 24 4
gpt4 key购买 nike

页面上基本上有两个 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 for type = First, one for type = Second

类似于 ng-repeat="event in events.type = 'First'"

最佳答案

您正在寻找 the filter filter ...

<tr ng-repeat="event in events | filter:{ type: 'First'}"/>

关于angularjs - Angular .js : ng-repeat based on item in object,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14367581/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com