繁体   English   中英

遍历AngularJS中的模块

[英]Iterate through module in AngularJS

我在AngularJS中遇到了这个问题; 我使用的是来自Github的拖放操作,也使用了嵌套的示例,但我也想实现身份类型,但是我无法遍历它给我的数组,因为我真的不知道如何。

list: [
0: {
type: container
allowedTypes: [ ... ]
id: Desayuno
columns: [ ... ]
}
1: {
type: container
allowedTypes: [ ... ]
id: Colación
columns: [ ... ]
}

我只需要allowedTypes值...我已经尝试过了:

<ul dnd-list="list"
dnd-allowed-types="(key, allowedTypes) in list">
<h3>{{list.id}}</h3>

但这给了我错误..

阅读此lib的文档,您的列表中有问题。 首先,它应该是一个对象。 其次,密钥应为字符串(不确定,但可以尝试)。 最后,对象应嵌套在数组中。 所以应该是这样的:

list: {
'0': [{
        type: container,
        allowedTypes: [ ... ],
        id: Desayuno,
        columns: [ ... ]
}],
'1': [{
        type: container,
        allowedTypes: [ ... ],
        id: Colación,
        columns: [ ... ]
    }]
}

另外,您应该修改html以在列表中获取正确的元素。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM