The malfunction of Angular's tree component

After installing and importing the Angular tree component, I followed the basic example provided in order to set it up. However, upon following the steps outlined on , I encountered an issue where only the root node is visible without expanding. Could someone please take a look at the code below to identify any potential errors? Your help in understanding this apparent error would be greatly appreciated.

Module:

import { NgModule } from '@angular/core';
import { TreeModule } from 'angular-tree-component';

@NgModule({
  imports: [
    TreeModule
  ],
  declarations: [],
  providers: []
})
export class CourseCreationModule { }

Component:

import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';

@Component({
  selector: 'app-container',
  templateUrl: './container.component.html',
  styleUrls: ['./container.component.css']
})
export class ContainerComponent implements OnInit {
  tree: any;

  constructor() { }

  getCourseDetails() {
      this.createLessonTree();
  }

  createLessonTree() {
    this.tree = [
      {
        id: 1,
        name: 'root1',
        children: [
          { 
            id: 2, 
            name: 'child1'
          },
          { id: 3, 
            name: 'child2'
          }
        ]
      },
      {
        id: 4,
        name: 'root2',
        children: [
          { id: 5, name: 'child2.1' },
          {
            id: 6,
            name: 'child2.2',
            children: [
              { id: 7, name: 'subsub' }
            ]
          }
        ]
      }
    ];
  }

ngOnInit() {
this.route.params.subscribe(params => {
  this.courseId = params['id'];
  this.getCourseDetails();
});
}

HTML:

<tree-root [nodes]="tree"></tree-root>

Based on my initial assessment, there seem to be no syntax errors since both root1 and root2 are visible.

Thank you for your assistance.

Answer №1

Successfully incorporated

@import '~angular-tree-component/dist/angular-tree-component.css';
into the src/styles.css document.

Answer №2

In order to properly initialize the course details, it is essential to invoke the getCourseDetails() method either within the constructor or in the ngOnInit() function as specified in the class declaration.

Answer №3

In case you are facing this issue post migration to @circlon/angular-tree-component, make sure to incorporate the following line:

@import '~@circlon/angular-tree-component/css/angular-tree-component.css'
in your src/styles.css. For further details, refer to the changelog

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Dominant Editing through ASP.Net Roles

Looking for guidance on how to effectively use knockout with asp.net membership roles in MVC 4. My goal is to incorporate an editable grid on the page based on whether the user is an administrator or a 'registered user'. I want to ensure that use ...

What is the best way to align HTML inputs within a grid, whether it be done automatically or manually using JavaScript?

Arrange 20 HTML inputs with various data types into grid-columns as the user inputs data. Ensure that the grid container has div elements correctly positioned for output. ...

What sets apart route.use(), route.all(), and route.route() in Express?

Is it possible to replace router.all() with router.use() if the former just matches all methods? Also, what are the differences between using router.use() and router.route()? ...

What is the best way to add a component into a MAP of other components in a React application?

I have a project where I am implementing a MAP function to iterate through an array of objects and present the data using a special Card component. However, I want to include another component called Banner after every second Card element from the loop, an ...

Looking to retrieve the full browser URL in Next.js using getServerSideProps? Here's how to do

In my current environment, I am at http://localhost:3000/, but once in production, I will be at a different URL like http://example.com/. How can I retrieve the full browser URL within getServerSideProps? I need to fetch either http://localhost:3000/ or ...

Encountering difficulties in retrieving the JSON data from the web service

My external web service contains JSON data which has been validated using the JSON Validator website. However, I am facing an issue where the success function in the code below is not running at all. The web service necessitates that the email and password ...

Sending information (prop) from _app.js to getServerSideProps in a page on the most up-to-date version of NextJS

I have a unique custom _app.js that I created: const CustomLayout = ({ children }) => (children); const myApp = ({ Component, pageProps }) => { pageProps.url = 'another url'; return ( <CustomLayout> <Co ...

Glowing beams of light emitted by point light in three.js

Is there a way to visualize light rays from a point light in a Three.js scene without affecting the entire scene with fog color? var width = $('#g_pre_emo').width(); var scene = new THREE.Scene(); scene.fog = new THREE.Fog(0xffff00, 0, 10); ...

Error message with ThreeJS ObjectLoader: "unable to interpret the 'fog' property as it is not defined"

Currently, my setup involves using ThreeJS to import a scene as shown in the code snippet below: $(document).ready(function(){ var scene = new THREE.ObjectLoader().load("scene.js"); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / ...

The process of automatically formatting Typescript has transformed into an unfortunate auto-discarding action

Typescript autoformatting has become a concerning issue. Whenever I input quoted strings (" or `), the code surrounding it seems to temporarily glitch, with other strings appearing as code. This problem has recently escalated, particularly with strings li ...

Selenium encountered an error when trying to execute the 'querySelector' function on the document. The selector provided, my_selector, is not recognized as a valid selector

Whenever I run this code: document.querySelector(my_selector) using selenium, an error is thrown: Failed to execute 'querySelector' on 'Document' my_selector is not a valid selector my_selector is definitely a valid selector that func ...

The drop-down button unexpectedly disappears when using Bootstrap in combination with jQuery autocomplete

I have some javascript code that is structured like: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>jQuery UI Autocompl ...

ngResource/$resource injection was not done correctly

I am currently working on developing a client for an API, and I am encountering an issue with the $resource module not being correctly injected. Despite adding ngResource to the module and passing it into the factory declaration, I am facing an error when ...

Navigating the use of property annotations in Mapped Types with remapped keys

After exploring the concept of Key Remapping in TypeScript, as shown in this guide, I am wondering if there is a way to automatically inherit property annotations from the original Type? type Prefix<Type, str extends string> = { [Property in keyo ...

Utilize AJAX to retrieve the output of a PHP randomizer

Current situation: I have a PHP file with a randomizer function and HTML that utilizes this function to display strings from a separate text document. The Function: <?php function rand_line($fileName, $maxLineLength = 4096) { $handle = @fopen($fileN ...

What is the best way to retrieve the outcomes of .query within a class?

Currently, I am working on a NodeJS application using coffee script. My objective is to save the results of a sql query executed by a class into a variable that can be returned by that same class. This is what I have so far: class dataBase mySQL = requ ...

Angular 7: Utilizing the Global Guard and implementing the CanDeactivate interface

Having just started diving into Angular, I've hit a roadblock in my search for a solution to my current issue. The problem at hand is that all global error messages persist even when switching to a different route. In an attempt to tackle this probl ...

Text Input Recognition Chrome Extension with a Pop-Up Display Feature

One feature of the Chrome Extension I developed allows users to input a string into a textfield and check if any words entered match items in an array. If the user's string includes a specific word from the array, I want it to be replaced with a clic ...

Limit the exposure of Jest globals in TypeScript to specific files

After including @types/jest in my package.json file, TypeScript and VS Code now consider all .ts files to have additional global variables such as test, describe, expect, afterAll, afterEach, and beforeEach. Is there a way to specify that these globals sho ...

Can a background image flow into another div?

My goal is to use this specific image as the background image for this particular page. I want the background image to begin within the navbar navbar-default class. However, I'm facing an issue. I need the image to extend into the next div, which is d ...