Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ivh-treeview for Facets and Count #70

Closed
brenthale opened this issue Sep 2, 2015 · 2 comments
Closed

Using ivh-treeview for Facets and Count #70

brenthale opened this issue Sep 2, 2015 · 2 comments
Labels

Comments

@brenthale
Copy link

I'm trying to use ivh-treeview as a way of Filtering with Facets. I'm getting Facet counts back from Solr and am trying to append the counts to the appropriate node in the treeview.

I started playing with templates and noticed this disclaimer: "The template itself does not (currently) have access a transcluded scope."

I assume this is why I am unable to see the counts I am placing on $scope. I am currently trying to do this:

            <div ivh-treeview="whatModel"
                ivh-treeview-expand-to-depth="1"
                ivh-treeview-filter="myFilterQuery">

                <script type="text/ng-template">
                    <div title="{{trvw.label(node)}}">
                      <span ivh-treeview-toggle>
                        <span ivh-treeview-twistie></span>
                      </span>

                      <span ng-if="trvw.useCheckboxes()" ivh-treeview-checkbox>
                      </span>

                      <span class="ivh-treeview-node-label" ivh-treeview-toggle>
                         {{trvw.label(node)}} - {{whatFacetCounts[trvw.label(node)]}}
                      </span>

                      <div ivh-treeview-children></div>

                    </div>
                </script>

The text alludes to the fact that "currently" it does this. Is there a chance we can get access to $scope variables inside of the template?

Can I get access to $scope variables when I use global or inline templates?

@jtrussell
Copy link
Contributor

You are correct. The "transcluded" template option is right now really a convenience for passing a template string to the treeview directive - these templates behave just like those provided inline or through the global options. They do not have access to the transcluded scope and so can't see things you're placing on $scope.

I had initially hoped to support the behavior you're looking for but ran into issues and tabled it for the moment. IIRC it was something to do with the helper directives requiring ivhTeeview as a parent directive and not finding it when compiled independently by ivhTreeviewCompiler.

Apologies for the inconvenience, I do plan to revisit this once the v1 branch drops. For the moment you'd have to work around this by either sticking the count (or a way to get it) on the node directly, e.g. {{node.facetCounts}} or using a directive to get the counts from a service, e.g. <span what-facet-counts="node"></span>.

@brenthale
Copy link
Author

Thanks for the tip about sticking the count on the node directly. I'm still learning about how cool Javascript is that way. It worked like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants