Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.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
AngularJS 1.4.8-如何仅在第一次显示ng重复文本_Angularjs_Twitter Bootstrap - Fatal编程技术网

AngularJS 1.4.8-如何仅在第一次显示ng重复文本

AngularJS 1.4.8-如何仅在第一次显示ng重复文本,angularjs,twitter-bootstrap,Angularjs,Twitter Bootstrap,我有一个类别、子类别和产品的列表要显示,我只想在第一次重复时显示类别和子类别。 像 我想显示如下列表 fruit - apple McIntosh Cortland cookies - chocolate Cocolatos 我使用了ng repeat和bootstrap class=“row”,但我无法仅第一次显示类别 感谢您应该在“catagory”属性上使用一个函数(下划线库有这个现成的函数,我打赌lodash也有),然后您需要使用嵌套的ng r

我有一个类别、子类别和产品的列表要显示,我只想在第一次重复时显示类别和子类别。 像

我想显示如下列表

fruit - apple
       McIntosh
       Cortland
cookies - chocolate
       Cocolatos
我使用了ng repeat和bootstrap class=“row”,但我无法仅第一次显示类别

感谢

您应该在“catagory”属性上使用一个函数(下划线库有这个现成的函数,我打赌lodash也有),然后您需要使用嵌套的
ng repeat
s来显示数据,第一个函数迭代新创建的组,而内部函数迭代产品


这是一个可以做到这一点的方法

一种方法是使用模块的groupBy过滤器。另一种方法是预处理数据,以便可以使用嵌套的ng repeat。我最终决定将后端结构更改为ng repeat友好型,这也减少了响应大小。
fruit - apple
       McIntosh
       Cortland
cookies - chocolate
       Cocolatos