Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在“角度”中隐藏过滤器上的组_Javascript_Angularjs - Fatal编程技术网

Javascript 在“角度”中隐藏过滤器上的组

Javascript 在“角度”中隐藏过滤器上的组,javascript,angularjs,Javascript,Angularjs,我的REST API正在返回分组数据 { "Homer Simpson": [ { "name": "First article", "type": "text" }, { "name": "Second article", "type": "text" } ], "Marge Simpson": [ { "name": "Third article" "type": "t

我的REST API正在返回分组数据

{
  "Homer Simpson": [
    {
      "name": "First article",
      "type": "text"
    },
    {
      "name": "Second article",
      "type": "text"
    }
  ],
  "Marge Simpson": [
    {
      "name": "Third article"
      "type": "text
    }
  ]
}
可以筛选以下文章:

<input type="text" placeholder="Quicksearch" ng-model="quicksearch">
...
<div class="article-group" ng-repeat="(author, articles) in articles">
  <h3>{{author}} ({{filtered.length}})</h3>
  <div class="article" ng-repeat="article in articles | filter: { name: quicksearch } as filtered">

...
{{author}}({{filtered.length}})
这里重要的是
({{filtered.length}})
。通过在quicksearch输入中键入内容应用过滤器后,长度会发生变化。一切都很好,但我想隐藏“空”作者;如果你输入“第三”,你就不会再看到荷马·辛普森了


尝试了
article group
div上的
ng if=“filtered.length>0”
,但无效。

您只需将
ng show=“filtered.length”
放在
上。article group
容器:

<div class="article-group" ng-show="filtered.length" ng-repeat="(author, articles) in articles">
  <h3>{{author}} ({{filtered.length}})</h3>
  <div class="article" ng-repeat="article in articles | filter: { name: quicksearch } as filtered">
    <pre>{{ article | json }}</pre>
  </div>
</div>

{{author}}({{filtered.length}})
{{文章| json}}

正是我想要的。谢谢