leovo2708 / ngx-treeview

An Angular treeview component with checkbox
MIT License
362 stars 337 forks source link

How Can Use Tree Multiple Time In Single Page? #227

Open hirenkukadiya opened 5 years ago

hirenkukadiya commented 5 years ago

How to use ngx-dropdown-treeview in multiple time page? what can i changes is template or something id any other options, because currently use two times bus there are is something like below :

ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngSwitch: false'. Current value: 'ngSwitch: true'

So, How can use tree multiple time in single page.? any example or code. Thanks.

TobiasPfeifer commented 5 years ago

I'm facing the same issue when using 'ngx-dropdown-treeview' in different components that get rendered to the same page. A component should be reusable (including multiple instances even within the same component).

I think the underlying reason for this bug is that one instance of 'ngx-dropdown-treeview' changes state of all 'ngx-dropdown-treeview' on the same page:

<ngx-dropdown-treeview id="first">
              [items]="items"
              [(value)]="selectedValue"
              (valueChange)="onValueChange($event)"
</ngx-dropdown-treeview>

<ngx-dropdown-treeview id="second">
</ngx-dropdown-treeview>

When selecting an item from the dropdown-treeview with id "first", the selected result will also be displayed in the dropdown-treeview with id "second". However their internal state should not depend on each other since they are not linked in any way.

Please let me know if more information on how to reproduce this bug is needed

I'm using "ngx-treeview": "^6.0.2"