无法在Angular中渲染树状结构?

时间:2018-07-24 12:00:41

标签: javascript html typescript treeview angular5

嗨,我正在Angular 5中开发Web应用程序。我正在尝试显示树状结构。我正在

  

https://github.com/500tech/angular-tree-component/blob/master/example/cli/src/app/async/async.component.ts和   https://angular2-tree.readme.io/docs/async-data-1

在上面的示例中,他们提供了一些数据,我的应用程序也可以使用它。实时地,我正在使用其他一些数据,并将其完全转换为他们给出的示例中的格式。

下面是我的例子。

 let results =  JSON.parse('{"userid":"e75792f8-cfea-460e-aca2-07a778c92a7c","tenantid":"00000000-0000-0000-0000-000000000000","username":"karthik","emailaddress":"john@krsars.onmicrosoft.com","isallowed":false,"userroles":[{"userroleid":"b81e63d1-09da-4aa0-af69-0f086ddb20b4","userid":"e75792f8-cfea-460e-aca2-07a778c92a7c","roleid":"85d2f668-f523-4b64-b177-b1a78db74234","tenantappid":1,"validfrom":"2018-01-24T00:00:00","validto":"2018-01-24T00:00:00","isactive":true}]}');
    for (const key in results) {
      if (results[key] instanceof Array) {
        const containerTyp2 = {name: '', hasChildren: false,};

        containerTyp2.name = key;
        containerTyp2.hasChildren = true;

        this.nodes.push(containerTyp2);
     } else {
        const object = {name: ''};
        const containerTyp1 = {name: '', children: []};
        object.name = results[key];
        containerTyp1.name = key;
        containerTyp1.children.push(object);
        this.nodes.push(containerTyp1);
    }
  }
  console.log(this.nodes);

下面是来自应用程序示例的示例数据。

  this.nodes = [
      {
        name: 'root1',
        children: [
          { name: 'child1' }
        ]
      },
      {
        name: 'root2',
        hasChildren: true
      },
      {
        name: 'root3'
      }
    ];

我正在将原始数据转换为与上述示例相同的格式。当我在控制台中显示两个数据时,除了id字段外,两个数据看起来都相似。每当我显示示例数据时,我都可以看到id字段被添加了随机值,但明确地它们并未添加。下面是示例数据的控制台。

enter image description here

下面是原始数据的控制台。

enter image description here

有人可以帮我解决问题吗?我无法确定不显示原始数据的原因是什么。任何帮助,将不胜感激。谢谢。

1 个答案:

答案 0 :(得分:0)

我通过在for循环的末尾添加以下行来解决此问题。

Q195353: FILE: VBUSC.EXE Provides Licensing for Discontinued Controls
Article: Q195353
Product(s): Microsoft Visual Basic for Windows
Version(s): 6.0
Operating System(s): 
Keyword(s): kbfile kbusage kbCtrl kbLicensing kbVBp kbVBp500 kbVBp600 kbGrpDSVB kbFAQ kbVBp600FAQ k
Last Modified: 21-JUN-2002

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual Basic Learning Edition for Windows, version 6.0 
- Microsoft Visual Basic Professional Edition for Windows, version 6.0 
- Microsoft Visual Basic Enterprise Edition for Windows, version 6.0 
-------------------------------------------------------------------------------

SUMMARY
=======

VBUSC.EXE is a file that installs the Design-Time Licenses for ActiveX controls
that shipped with earlier versions of Visual Basic, but are no longer supported
and have been discontinued with the current version.

MORE INFORMATION
================

The following file is available for download from the Microsoft Download
Center:

  VBUSC.exe
  (http://download.microsoft.com/download/VB60Pro/Install/2/Win98/En-US/VBUSC.exe)

Release Date: August 15, 2000

For additional information about how to download Microsoft Support files, click
the following article number to view the article in the Microsoft Knowledge
Base:

  Q119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current
virus-detection software that was available on the date that the file was
posted. The file is stored on secure servers that prevent any unauthorized
changes to the file.

   FileName               Size
  ---------------------------------------------------------
  VBUSC.EXE                88k

The following controls are no longer supported by Microsoft Visual Basic:

ActiveX Control Name                Filename
------------------------------------------------
Desaware Animated Button Control    ANIBTN32.OCX
Microhelp Gauge Control             GAUGE32.OCX
Pinnacle-BPS Graph Control          GRAPH32.EXE
Microsoft Grid Control              GRID32.OCX
Microhelp Key State Control         KEYSTA32.OCX
Microsoft Outline Control           MSOUTL32.OCX
Outrider SpinButton Control         SPIN32.OCX
Sheridan 3D Controls                THREED32.OCX

The ActiveX controls listed above are no longer supported, but ship with the
Professional and Enterprise Editions of Microsoft Visual Basic for backward
compatibility when upgrading existing projects.

These controls do not ship with the Learning Edition of Microsoft Visual Basic.

For the Professional and Enterprise Editions, the controls are located on the
installation CDs at the following locations:

Microsoft Visual Basic Edition        Location
----------------------------------------------------------------------
Professional 6.0                      \Common\Tools\VB\Controls
Enterprise 6.0                        \Common\Tools\VB\Controls
Visual Studio Professional 6.0        \Common\Tools\VB\Controls (CD2)
Visual Studio Enterprise 6.0          \Common\Tools\VB\Controls (CD3)


Each of these directories contain a README.TXT with instructions on how to
install the controls for design-time use.

NOTE: Using the Learning Edition to upgrade a project developed in an earlier
version of Microsoft Visual Basic might result in licensing problems for these
controls.

The VBUSC.EXE installs the design-time licenses for the controls listed above if
Visual Basic is detected on the computer.

REFERENCES
==========

For additional information, please see the following articles in the Microsoft
Knowledge Base:

  Q194784 INFO: Controls Shipped in Visual Basic 6.0

  Q172193 INFO: List of VB 4.0 Custom Controls Discontinued in VB 5.0