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

CdkTree does not populate some CdkTreeNodeOutletContext properties #12034

Open
revov opened this issue Jul 3, 2018 · 3 comments
Open

CdkTree does not populate some CdkTreeNodeOutletContext properties #12034

revov opened this issue Jul 3, 2018 · 3 comments
Labels
area: cdk/tree P4 A relatively minor issue that is not relevant to core functions

Comments

@revov
Copy link

revov commented Jul 3, 2018

Bug, feature request, or proposal:

Bug

What is the expected behavior?

CdkTreeNodeOutletContext has the following properties:

  /** Depth of the node. */
  level: number;

  /** Index location of the node. */
  index?: number;

  /** Length of the number of total dataNodes. */
  count?: number;

All of them should be populated when creating the context and before embedding the node (see code reference).

What is the current behavior?

Only level is populated. index and count are not populated and cannot be used in the TreeNode's template to track the current position or total count. I assume that index should be the index of the node, relative to its siblings in its branch at the same level, and count should be the total number of siblings in the same branch at that level.

What are the steps to reproduce?

When using all three properties of the context, only level is populated - see Stackblitz example

What is the use-case or motivation for changing an existing behavior?

Developers should have access to the node's current position in their template, similarly to how they can track index in ngFor.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

All

@josephperrott josephperrott added the P4 A relatively minor issue that is not relevant to core functions label Jul 16, 2018
@majoraze
Copy link

majoraze commented Apr 9, 2019

Lost so many hours with this because the official documentation says this properties are exposed:
https://material.angular.io/cdk/tree/api#CdkTreeNodeOutletContext

At least remove this from the documentation to not confuse the developers.

@armved
Copy link

armved commented Feb 20, 2020

Have the same issue. I can't connect node data to formArray because I need row's index which is not provided.
I've just tried to add context.index = index in insertNode() function and everything worked out perfectly. Is that a correct solution?
image

@Jacobra93
Copy link

I noticed that index is still not populated, is there a timeframe for when this will be added or at least removed from the docs? Unless I am trying to get the index wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: cdk/tree P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

6 participants