【发布时间】:2013-03-12 17:59:02
【问题描述】:
我知道ng-repeat的基本用法,我可以很容易地生成一个列表。
<ul>
<li ng-repeat="presentation in presentations">
{{presentation.title}}
</li>
</ul>
我有一个从 PHP 返回的数组:
presentations = Array
(
[0] => stdClass Object (
[collection] => Collection A
[title] => Title 1a
)
[1] => stdClass Object (
[collection] => Collection A
[title] => Title 2a
)
[2] => stdClass Object (
[collection] => Collection B
[title] => Title 1b
)
[3] => stdClass Object (
[collection] => Collection B
[title] => Title 2b
)
[4] => stdClass Object (
[collection] => Collection C
[title] => Title 1c
)
[5] => stdClass Object (
[collection] => Collection C
[title] => Title 2c
)
[6] => stdClass Object (
[collection] => Collection C
[title] => Title 3c
)
)
您会注意到每个对象都有一个collection。
我基本上需要为每个集合创建一个标题视图。我需要它显示如下:
COLLECTION A
- Title 1a
- Title 2a
COLLECTION B
- Title 1b
- Title 2b
COLLECTION C
- Title 1c
- Title 2c
- Title 3c
只有标题是可点击的。这可能与ng-repeat 有关吗?我知道我可以在 PHP 中将每个集合排序到单独的数组中。我应该先这样做吗?如果可能的话,我想只使用ng-repeat,我只是不知道如何处理这个问题。
我计划在 nav-list 中显示此列表,使用 twitter 引导程序定义。
【问题讨论】:
标签: php javascript twitter-bootstrap angularjs