angular-tree-component | fetch Path

Can someone help me figure out how to retrieve the full path when clicking on a node? I noticed there is a path option in the API, but I'm unsure of how to incorporate it with the click event.

options: ITreeOptions = {
 actionMapping: {
 mouse: {
 dblClick: (tree, node, $event) => {

 }
 }
}

Answer №1

If you require a specific format, you have the option to construct the lineage/path on your own

config: ITreeConfig = {
    eventHandlers: {
        doubleClick: (tree, node, $event) => {
            const pathElements = [];
            // include clicked node as initial element
            pathElements.push(node.data);

            // get parent of clicked node
            let parent = node.parent;

            // iterate through parents until reaching the tree root
            while(parent !== null){
                pathElements.push(parent.data);
                parent = parent.parent;
            }
        }
    }
}

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

Save the current page URL from Angular app into a MongoDB database

I'm currently working on an Angular project and trying to find a way to easily copy the current page URL and store it in MongoDB. Here is the URL: http://localhost:4201/contact?pincode=4343&devicetype=desktop&country=india Any suggestions wo ...

A guide to identifying a user's browser type using server-side code (Node.js) when making an API request

Can someone help me differentiate between REST API calls made from a desktop browser and those from a mobile browser, specifically tablets? I am currently using Node Express on my server side. ...

HttpClient - Transforming a Json array outcome by modifying certain values

Encountering an issue with the updated HttpClient. In the past, I was able to convert a JSON array of users into User[] using reduce like so: export class User { constructor( public userId: number, public username: string, pub ...

Compilation error in Angular 7 development process

Using Angular 7, npm 5.5.1 and node 8.9.0 In the terminal... npm run build:test <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5435252503736d736d73">[email protected]</a> build:test C:\Projects\fff ng ...

I can see my Angular 2 object displayed on the console, however, the specific properties are not showing up in the template

Below is the template and component code snippet that I am working with: Template: <div *ngIf="newJobCreated"> <h3>Name: {{newJob.name}}</h3> <h3>Job: {{newJob.job}}</h3> <h3>ID: {{newJob.id}}&l ...

Waiting for Angular's For loop to complete

Recently, I encountered a situation where I needed to format the parameters and submit them to an API using some code. The code involved iterating through performance criteria, performance indicators, and target details to create new objects and push them ...

Why does FormGroup.Get() return null when there is a period in the name of the FormControl?

Issue: I am facing an issue with the formGroup I created using formbuilder. The problem arises when a control within the FormGroup contains a . in its name. When attempting to retrieve the formControl using the formGroup.get method, it returns null. Sampl ...

Difficulties Arising in Flex Layout Usage Due to ngFor Loop Implementation

Despite my efforts, I couldn't locate a question quite similar to mine. If an answer already exists somewhere, I apologize. I'm trying to create a simple flex layout in row format where 2 containers are placed side by side. Inside another compon ...

Exploring the SOLID Design Principles through TypeScript

Recently, I came across an intriguing article discussing the SOLID principles and delving into the concept of the Dependency Inversion Principle (DIP). The article presented an example to illustrate this principle using both an incorrect and a correct appr ...

Having trouble implementing Bootstrap 4 Carousel in Angular 2? Getting an error message that says: "Property 'carousel' does not exist on type 'JQuery'?"

I'm currently working on implementing a Bootstrap 4 carousel within my Angular 2 application. My goal is to achieve the same full-width effect demonstrated here. I've made progress up to the point where I need to link the element to the carousel: ...

Problem with Rx.ReplaySubject subscription: callback is not triggering

In my project, I have a ReplaySubject from rxjs that emits a value or null based on the environment. This means that if I am in a certain environment, a service call is made to fetch data and emit it. If not, null is just emitted using next(null) on the re ...

Discover the inner workings of Angular Universal with Angular 11 by exploring the page source

Attempting to update the script type application/ld+json src in Angular Universal after user actions. const newScript:HTMLScriptElement = document.createElement('script'); newScript.setAttribute('type', 'application/ld+json') ...

Discovering the best approach to utilizing Font Awesome 6 with React

Required Packages "@fortawesome/fontawesome-svg-core": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/react-fontawesome": "^0.1.18", "next": " ...

Create a function that is identical to the original, but omits the final

I am currently working on defining a type B that functions similarly to type A, but without the last parameter. I have attempted the solution below, however, it is still requiring 2 parameters instead of just one. type Callback = (msg: string) => void; ...

Publish an Angular application's production version using Zeit Now

I've been utilizing zeit now for deploying an Angular application. The steps I followed can be found in this guide. The Angular app was created using the Angular CLI and was developed locally using the command ng serve. Deployment was done by executi ...

Disabling the range selection in the mat-date-range-picker when the date is disabled

I am trying to use the mat-date-range-picker feature to prevent users from selecting a date range that includes disabled dates. In the provided example (available at this stackblitz url: https://stackblitz.com/edit/angular-rbeehp?file=src%2Fapp%2Fdate-ran ...

The functionality of http.delete is smooth when tested on Postman, but encountering issues on Angular 4/Ionic 3 application

I am new to working with the Angular 2/Spring boot stack, so please bear with me as I navigate through this. I have implemented an http.delete method for deleting a specific row selected by the user with a confirmation alert. While the API request works p ...

Exploring query parameters for the main component within Angular IO

I'm working on a basic Angular 4+ application that pulls data from an API and displays it. My approach involves utilizing the root component as follows: {path: 'main', component: MainComponent} along with QueryParams such as ?id=1. Although ...

What is the best way to incorporate file paths into a tree or stack data structure in C++?

I am currently working on a task that involves searching, renaming, or deleting files and folders from a specified drive on the computer by utilizing a data structure (such as a tree, stack, or queue). My query is regarding how to integrate file paths an ...

Resetting the Angular2 poller in an ng-bootstrap accordion

I am currently utilizing a multi-dimensional array connected to a reactive poller that waits for a database state update. Interestingly, when I initially load the state once, the user interface functions as intended. However, a challenge arises when I act ...