简体   繁体   English

JSON循环引用角度错误

[英]JSON circular reference Angular Error

I am trying to implement a tree in AngularJS. 我正在尝试在AngularJS中实现一棵树。 I have to build the tree(ie add nodes to tree), dynamically based on user input(from Angular Select). 我必须基于用户输入(来自Angular Select)动态地构建树(即,将节点添加到树)。 Here is the operation I want to do, 这是我要执行的操作

var a = { name : "concat", operands : [{method : {}},{method : {}}]}; a.operands[0].method = a;

When I try to do this kind of operation in AngularJS, I am getting RangeError: Maximum call stack size exceeded. 当我尝试在AngularJS中执行此类操作时,出现RangeError:超出了最大调用堆栈大小。 is something wrong with this kind of operation. 这种操作有问题。

I am getting this error, because the Array populating the dropdown is getting modified every time and causing this error. 我收到此错误,因为填充下拉列表的数组每次都被修改并导致此错误。 Sorry for the inconvenience. 抱歉给你带来不便。

I think, something is missing in your code. 我认为您的代码中缺少某些内容。 If you can share your code then I will be able to help more. 如果您可以共享您的代码,那么我将能够提供更多帮助。 Or you can checkout this blog . 或者您可以签出此博客 In this blog, we are creating a tree with two small directive. 在此博客中,我们正在创建带有两个小指令的树。 You can modify directive according to your requirement. 您可以根据需要修改指令。

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

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