NgHierarchicalSelector icon indicating copy to clipboard operation
NgHierarchicalSelector copied to clipboard

issue when selection and onSelectionChanged are bound to same scope variable

Open anupamN opened this issue 9 years ago • 3 comments

I am facing an issue when i bind selection and onSelectionChanged to same scope variable. For Example,

        <hierarchical-selector id="product"
                               class="tree-browser"
                               ng-model="searchModel.products"
                               data="productHierarchy"
                               on-selection-changed="searchModel.products = items"
                               multi-select="true"
                               selection="searchModel.products"
                               no-button/>

I am using selection to display default selected values when page loads for the first time. When user manually changes the selected nodes on the tree, itemSelected is called which calls onSelectionChanged. The watch on selection is triggered as both are bound to same variable. This in turn calls itemSelected and so on. The code goes into an infinite loop and the web page freezes. Is there a solution to the problem?

anupamN avatar Aug 24 '15 09:08 anupamN

Yep, I'm also waiting for fix for that issue=)

BaurzhanSakhariev avatar Oct 01 '15 12:10 BaurzhanSakhariev

@lukemurray, could you please give me an idea to fix it by myself? What scripts and functions should be investigated?

BaurzhanSakhariev avatar Nov 12 '15 05:11 BaurzhanSakhariev

Hmm that is weird.I'd look at the hierarchical-selector directive, and see what it is doing with the attributes. I think it wants onSelectionChange to be a function...

What happens if you change onSelectionChanged to a function on the scope and in the function assigned the value?

lukemurray avatar Nov 12 '15 11:11 lukemurray