Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

tree.treeModel.expandAll() Not working for 'angular2-tree-component'

See original GitHub issue

Hi @adamkleingit

I have been enjoying using angular2-tree-component for my tree implementation.

I haven’t seen any problems until I tried to expandAll()

Here is the webpackbin URL with issue reproduce

I am using ‘angular2-tree-component’ v3.1.0

I found


not working properly for async node structure when I import TreeModule from 'angular2-tree-component'

import { TreeModule } from 'angular2-tree-component';


import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { TreeModule } from 'angular2-tree-component';

import { AppComponent } from './app.component';

  declarations: [
  imports: [
  providers: [],
  bootstrap: [AppComponent]
export class AppModule { }

expandAll() working fine when I import TreeModule from 'angular-tree-component'

import { TreeModule } from 'angular-tree-component';

I m using Chrome Version 60.0.3112.113

I have to use 'angular2-tree-component' in my project, also if you could explain what is difference between 'angular2-tree-component' and 'angular-tree-component' as I found both are working with angular 2 and 4.

Can you please help me here

Thanks! Regards Abhi

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

erickyi2006commented, Jan 29, 2018

I found a different issue for dynamic nodes. For static nodes, expandAll() works. The problem I found is that when I update the nodes dynamically, I can’t expand the updated nodes. I also discovered a work around solution (see below). FYI, i am using the latest version ( “angular-tree-component”: “^7.0.1”)

  ngAfterViewInit() {
    this.tree.treeModel.expandAll(); // works first time

  someEvent () {
      this.nodes = [
          id: 1,
          name: 'newRoot1',
          children: [
            { id: 2, name: 'new.child1' },
            { id: 3, name: 'new.child2' }
      this.tree.treeModel.expandAll(); // does not work

Here is the work around.

// in html file, add updateData event

  <tree-root #tree [nodes]="nodes" [options]="options" (updateData)= "onUpdateData(tree, $event)">
    <ng-template #treeNodeTemplate let-node let-index="index">
        <span>{{ }} 
        <span class="tree-node-value">

// in ts file
  onUpdateData (treeComponent: TreeComponent, $event) {
    console.log ("onUpdateData", treeComponent, $event);

Probably I missed a step somewhere, but the work around works. Maybe the developers can shed a light on why I need to implement this work around.

crivadavicommented, Sep 22, 2017

‘angular2-tree-component’ is the old module, then it was renamed to angular-tree-component. You should use angular-tree-component because this is updated to version 5.0.0 at 2017-01-09 (see the changelog). That is the reason why import TreeModule from angular-tree-component works!

Read more comments on GitHub >

github_iconTop Results From Across the Web

tree.treeModel.expandAll() Not working for 'angular2 ... - GitHub
I found a different issue for dynamic nodes. For static nodes, expandAll() works. The problem I found is that when I update the...
Read more >
angular2-tree-component is not expanded by default
The Expand All button calls the tree.treeModel.expandAll() method. Share.
Read more >
Expanding nodes on init - Getting Started
A common use case is to start with the tree expanded completely. You can achieve this by calling treeModel.expandAll() after view init: JavaScript....
Read more >
@circlon/angular-tree-component - npm
A simple yet powerful tree component for Angular. Latest version: 11.0.4, last published: 2 years ago.
Read more >
Angular6 Tree Component Filtering Does Not Work - ADocLib
treeModel.update() explicitly in onMoveNode event also, but doesn't help Could you simple why to get event click on item in the angular2-tree-component The ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found