1

js`,我想将一个数组重复到一个列表中

由此: 这是在服务中:

var Response= [
        ["Article One"],
        ["Article Two"],
        ["Article Three"],
        ["Article Images", ["Images 1", "Images 2", "Images 3"] ],
        ["Article Five"]
    ];

并从控制器调用对象:

$scope.Response = function () {
        return ArtikelSucheService.Response;
    };

我想这样重复:

<ul ng-repeat="Article in Response()">
        <li>Article One</li>
        <li>Article Two</li>
        <li>Article Three</li>
        <li>Images 
            <ul ng-repeat="What must stay here?">
                <li>Images 1</li>
                <li>Images 2</li>
                <li>Images 3</li>
            </ul>
        </li>
        <li>Article Five</li>
   </ul>

我不知道,我怎样才能在一个数组中重复一个数组。响应是一个数组。在响应中有 x 个图像。1 篇文章可以有很多图片。

有人可以帮帮我吗?

4

2 回答 2

0

可能像下面这样?

<ul>
  <li ng-repeat="Article in Response()">
    {{ Article[0] }}
    <ul ng-show="Article[1]">
      <li ng-repeat="img in Article[1]">{{ img }}</li>
    </ul>
  </li>
</ul>
于 2013-02-04T10:02:21.140 回答
0
var Response1= [
        ["Article One"],
        ["Article Two"],
        ["Article Three"],
        ["Article Images", ["Images 1", "Images 2", "Images 3"] ],
        ["Article Five"]
];

并在 html 中使用下面的模板

<ul>
  <li ng-repeat='option in responses1'>
      {{option[0]}}
      <ul>
      <li ng-repeat='suboption in option[1]'>{{suboption}}</li>
    </ul>
      </li>
    </ul>

工作小提琴 http://jsfiddle.net/jw5Qf/1/

于 2013-02-04T09:55:45.500 回答