Skip to content

How to check the type of children component? #1953

@f15gdsy

Description

@f15gdsy

Hi,

I want to do something like:
The parent component displays the number of its children components of a specific type.
An example:

// Should display 3
<Parent>
  <div>{{ numOfChildComponents }}</div>
  <Child></Child>
  <Child></Child>
  <Hello></Hello>
  <Child></Child>
</Parent>

How should I achieve this?

I saw an implementation to assign a specific class to the children,
and then in the parent component it uses jQuery to find out the children of that class.
This works but I'm wondering if there is less jQuery or DOM approach to achieve this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions