AngularJS:嵌套纳克重复(阵列中物体)仅工作,如果有在阵列一项,而不是当多个 [英] AngularJS: nested ng-repeat (array in object) only works if there is one item in array, not when multiple

查看:173
本文介绍了AngularJS:嵌套纳克重复(阵列中物体)仅工作,如果有在阵列一项,而不是当多个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有一个奇怪的问题。我有对象的数组。每个对象都包含(字符串),另一个数组。我循环中使用 NG-重复对象的数组。在重复code I NG-重复字符串数组。出于某种原因,这种嵌套的 NG-重复当字符串数组包含但一(1)项只适用。当有更多的项目,它根本不起作用。

Okay, I have a weird issue. I have an array of objects. Each object contains another array (of strings). I loop over the array of objects using ng-repeat. Within the repeated code I ng-repeat over the array of strings. For some reason, this nested ng-repeat only works when the array of strings contains but one (1) item. When there are more items, it simply doesn't work.

code

&LT的结果{{answer.value | JSON}}< / pre>

[
  "Apothekerskast",
  "Apothekerskast",
  "Koelkast ombouw"
]

视图(在一个要点,因为在这里发帖会导致降价的问题):的 https://gist.github.com/fabdrol/898e4ac9760fc358ce81

The view (in a gist because posting here causes issues with markdown): https://gist.github.com/fabdrol/898e4ac9760fc358ce81

的数据(JSON),为方便阅读: https://gist.github.com/fabdrol / 089467fa09dad6e89e81

The data (in JSON), for easy reading: https://gist.github.com/fabdrol/089467fa09dad6e89e81

推荐答案

不喜欢重复

It doesn't like duplicates, use track by $index:

NG-重复=VAL瓦尔斯跟踪由$指数

的jsfiddle: http://jsfiddle.net/nedq13q2/

JSFiddle: http://jsfiddle.net/nedq13q2/

这篇关于AngularJS:嵌套纳克重复(阵列中物体)仅工作,如果有在阵列一项,而不是当多个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆