Javascript 如何从json中过滤数据

Javascript 如何从json中过滤数据,javascript,angularjs,json,Javascript,Angularjs,Json,我现在正在和angularJS一起做一个项目,我被这个问题困住了。我有一个问题,关于angularJS中的过滤器。我不知道如何从JSON中过滤一个特定属性 这是我的索引页的一部分 index.html <div class="container2"> <table class="table table-hover" ng-hide="hideTable2"> <tr> <th>Site U

我现在正在和angularJS一起做一个项目,我被这个问题困住了。我有一个问题,关于angularJS中的过滤器。我不知道如何从JSON中过滤一个特定属性

这是我的索引页的一部分

index.html

<div class="container2">
        <table class="table table-hover" ng-hide="hideTable2">
          <tr>
            <th>Site URL</th>
            <th>Group</th>
            <th>Edit</th>
          </tr>

          <tr ng-repeat="site in promise.sites | filter:{group:[""]}"  >
            <td>
                <a href="http://{{site.url}}" style="color:{{site.color}}; text-decoration:none">
                {{ ::site.siteName }} </a>

            <td>
            <div class = "btn-group">

                <button type = "button" class = "btn btn-primary"> Groups 
                <span class="badge">{{ ::site.group.length }}</span>
                </button>
                <button type = "button" class = "btn btn-primary dropdown-toggle" data-toggle = "dropdown">
                        <span class = "caret"></span>
                        <span class = "sr-only">Toggle Dropdown</span>
                </button>

                <ul class = "dropdown-menu" role = "menu" >
                    <li ng-repeat="g in site.group"><span>{{::g}}</span><hr></li>
                </ul>

            </div>
            <td>
                <button class="btn btn-primary" ng-click="toggleEditSites()">Edit</button>
            </td>
            <td>
                    <img src="images/glyphicons-208-remove.png" ng-click="deleteSites(site.id)"/>
            </td>

          </tr>
        </table>

我想按“站点”数组中的组属性进行筛选。如果有人能向我解释这一点,我将非常高兴。非常感谢。

我想这正是您想要的:谢谢,这正是我需要的……)
{
  "sites":[
          {
                "id": 1,
                "siteName":"Google",
                "url": "www.google.com",
                "color": "green",
                "group": ["Social","Sport","Games","News","Programming"]
          },

          {
                "id": 2,
                "siteName":"Facebook",
                "url": "www.facebook.com",
                "color": "blue",
                "group": []
          },

          {
                "id": 3,
                "siteName":"B92",
                "url": "www.b92.net",
                "color": "red",
                "group": ["Social","Sport"]
          },

          {
                "id": 4,
                "siteName":"9GAG",
                "url": "www.9gag.com",
                "color": "purple",
                "group": []
          }
],

  "groups":[
        {
                "id":1,
                "name":"Search Engine",
                "color":"green",
                "sites":["Google","Yahoo","Bing"]
        },
        {
                "id":2,
                "name":"Social",
                "color":"red",
                "sites":[]
        },
        {
                "id":3,
                "name":"Games",
                "color":"blue",
                "sites":[]
        },
        {
                "id":4,
                "name":"Informations",
                "color":"red",
                "sites":[]

        },
        {
                "id":5,
                "name":"Sport",
                "color":"orange",
                "sites":[]
        },
        {
                "id":6,
                "name":"Television",
                "color":"green",
                "sites":[]
        }
]
}