Angularjs想要使用动态键值对遍历ng-repeat的子对象 [英] Angularjs wanted to iterate through sub-objects of ng-repeat with dynamic key value pair

查看:474
本文介绍了Angularjs想要使用动态键值对遍历ng-repeat的子对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSON对象,我正在迭代它。



但是,每个迭代对象都有一些子对象,我需要迭代它们。



JSON结构: - [{name:a,t1:v1,t2:v2,t3:{c1:cv1,c2:cv2 ...}} ]



这个JSON对象有(key,value)对,value可以让它的子节点再次与(key,value)配对。



我想为每个键值对和子键值对创建标签。



提前致谢,

Ashok。



我尝试过:



I have a JSON object and I am iterating through this.

But, each iterated object has some child objects where I do need to iterate through them as well.

JSON structure:- [{name: a, t1:v1, t2:v2, t3:{c1:cv1,c2:cv2 ...}}]

This JSON object has (key, value) pair and value can have its children with (key, value) pair again.

I wanted to create labels for each key value pair and for child key value pair also.

Thanks in advance,
Ashok.

What I have tried:



< label style => {{key}}:< / label>

< label style =display:inline-block ;> {{value}}< / label>


<label style="">{{key}} :</label>
<label style="display:inline-block;">{{value}}</label>


{{attribute}}({{v}})


{{attribute}} ({{v}})




推荐答案

它对我有用



It worked for me

JSON.parse('{"1": 1, "2": 2, "3": {"4": 4, "5": {"6": 6}}}' ...


这篇关于Angularjs想要使用动态键值对遍历ng-repeat的子对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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